fluentd 1.16.5-x64-mingw-ucrt → 1.17.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -0
  3. data/README.md +2 -1
  4. data/Rakefile +1 -1
  5. data/SECURITY.md +2 -2
  6. data/fluent.conf +14 -14
  7. data/lib/fluent/command/binlog_reader.rb +1 -1
  8. data/lib/fluent/command/cap_ctl.rb +4 -4
  9. data/lib/fluent/compat/call_super_mixin.rb +3 -3
  10. data/lib/fluent/compat/propagate_default.rb +4 -4
  11. data/lib/fluent/config/configure_proxy.rb +2 -2
  12. data/lib/fluent/config/types.rb +1 -1
  13. data/lib/fluent/config/yaml_parser/parser.rb +4 -0
  14. data/lib/fluent/configurable.rb +2 -2
  15. data/lib/fluent/counter/mutex_hash.rb +1 -1
  16. data/lib/fluent/fluent_log_event_router.rb +0 -2
  17. data/lib/fluent/log/console_adapter.rb +4 -2
  18. data/lib/fluent/plugin/buf_file.rb +1 -1
  19. data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
  20. data/lib/fluent/plugin/buffer/file_single_chunk.rb +2 -3
  21. data/lib/fluent/plugin/filter_parser.rb +26 -8
  22. data/lib/fluent/plugin/in_exec.rb +14 -2
  23. data/lib/fluent/plugin/in_http.rb +19 -54
  24. data/lib/fluent/plugin/in_sample.rb +13 -7
  25. data/lib/fluent/plugin/in_tail.rb +99 -25
  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 +137 -13
  29. data/lib/fluent/plugin/owned_by_mixin.rb +0 -1
  30. data/lib/fluent/plugin/parser_json.rb +26 -17
  31. data/lib/fluent/plugin/parser_msgpack.rb +24 -3
  32. data/lib/fluent/plugin_helper/http_server/server.rb +1 -1
  33. data/lib/fluent/plugin_helper/metrics.rb +2 -2
  34. data/lib/fluent/registry.rb +6 -6
  35. data/lib/fluent/test/output_test.rb +1 -1
  36. data/lib/fluent/unique_id.rb +1 -1
  37. data/lib/fluent/version.rb +1 -1
  38. data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
  39. metadata +109 -459
  40. data/.github/ISSUE_TEMPLATE/bug_report.yml +0 -71
  41. data/.github/ISSUE_TEMPLATE/config.yml +0 -5
  42. data/.github/ISSUE_TEMPLATE/feature_request.yml +0 -39
  43. data/.github/ISSUE_TEMPLATE.md +0 -17
  44. data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
  45. data/.github/workflows/stale-actions.yml +0 -24
  46. data/.github/workflows/test.yml +0 -32
  47. data/.gitignore +0 -30
  48. data/Gemfile +0 -9
  49. data/fluentd.gemspec +0 -54
  50. data/test/command/test_binlog_reader.rb +0 -362
  51. data/test/command/test_ca_generate.rb +0 -70
  52. data/test/command/test_cap_ctl.rb +0 -100
  53. data/test/command/test_cat.rb +0 -128
  54. data/test/command/test_ctl.rb +0 -56
  55. data/test/command/test_fluentd.rb +0 -1291
  56. data/test/command/test_plugin_config_formatter.rb +0 -397
  57. data/test/command/test_plugin_generator.rb +0 -109
  58. data/test/compat/test_calls_super.rb +0 -166
  59. data/test/compat/test_parser.rb +0 -92
  60. data/test/config/assertions.rb +0 -42
  61. data/test/config/test_config_parser.rb +0 -551
  62. data/test/config/test_configurable.rb +0 -1784
  63. data/test/config/test_configure_proxy.rb +0 -604
  64. data/test/config/test_dsl.rb +0 -415
  65. data/test/config/test_element.rb +0 -518
  66. data/test/config/test_literal_parser.rb +0 -309
  67. data/test/config/test_plugin_configuration.rb +0 -56
  68. data/test/config/test_section.rb +0 -191
  69. data/test/config/test_system_config.rb +0 -195
  70. data/test/config/test_types.rb +0 -408
  71. data/test/counter/test_client.rb +0 -563
  72. data/test/counter/test_error.rb +0 -44
  73. data/test/counter/test_mutex_hash.rb +0 -179
  74. data/test/counter/test_server.rb +0 -589
  75. data/test/counter/test_store.rb +0 -258
  76. data/test/counter/test_validator.rb +0 -137
  77. data/test/helper.rb +0 -155
  78. data/test/helpers/fuzzy_assert.rb +0 -89
  79. data/test/helpers/process_extenstion.rb +0 -33
  80. data/test/log/test_console_adapter.rb +0 -110
  81. data/test/plugin/data/2010/01/20100102-030405.log +0 -0
  82. data/test/plugin/data/2010/01/20100102-030406.log +0 -0
  83. data/test/plugin/data/2010/01/20100102.log +0 -0
  84. data/test/plugin/data/log/bar +0 -0
  85. data/test/plugin/data/log/foo/bar.log +0 -0
  86. data/test/plugin/data/log/foo/bar2 +0 -0
  87. data/test/plugin/data/log/test.log +0 -0
  88. data/test/plugin/data/sd_file/config +0 -11
  89. data/test/plugin/data/sd_file/config.json +0 -17
  90. data/test/plugin/data/sd_file/config.yaml +0 -11
  91. data/test/plugin/data/sd_file/config.yml +0 -11
  92. data/test/plugin/data/sd_file/invalid_config.yml +0 -7
  93. data/test/plugin/in_tail/test_fifo.rb +0 -121
  94. data/test/plugin/in_tail/test_io_handler.rb +0 -150
  95. data/test/plugin/in_tail/test_position_file.rb +0 -346
  96. data/test/plugin/out_forward/test_ack_handler.rb +0 -140
  97. data/test/plugin/out_forward/test_connection_manager.rb +0 -145
  98. data/test/plugin/out_forward/test_handshake_protocol.rb +0 -112
  99. data/test/plugin/out_forward/test_load_balancer.rb +0 -106
  100. data/test/plugin/out_forward/test_socket_cache.rb +0 -174
  101. data/test/plugin/test_bare_output.rb +0 -131
  102. data/test/plugin/test_base.rb +0 -247
  103. data/test/plugin/test_buf_file.rb +0 -1314
  104. data/test/plugin/test_buf_file_single.rb +0 -898
  105. data/test/plugin/test_buf_memory.rb +0 -42
  106. data/test/plugin/test_buffer.rb +0 -1493
  107. data/test/plugin/test_buffer_chunk.rb +0 -209
  108. data/test/plugin/test_buffer_file_chunk.rb +0 -871
  109. data/test/plugin/test_buffer_file_single_chunk.rb +0 -611
  110. data/test/plugin/test_buffer_memory_chunk.rb +0 -339
  111. data/test/plugin/test_compressable.rb +0 -87
  112. data/test/plugin/test_file_util.rb +0 -96
  113. data/test/plugin/test_filter.rb +0 -368
  114. data/test/plugin/test_filter_grep.rb +0 -697
  115. data/test/plugin/test_filter_parser.rb +0 -731
  116. data/test/plugin/test_filter_record_transformer.rb +0 -577
  117. data/test/plugin/test_filter_stdout.rb +0 -207
  118. data/test/plugin/test_formatter_csv.rb +0 -136
  119. data/test/plugin/test_formatter_hash.rb +0 -38
  120. data/test/plugin/test_formatter_json.rb +0 -61
  121. data/test/plugin/test_formatter_ltsv.rb +0 -70
  122. data/test/plugin/test_formatter_msgpack.rb +0 -28
  123. data/test/plugin/test_formatter_out_file.rb +0 -116
  124. data/test/plugin/test_formatter_single_value.rb +0 -44
  125. data/test/plugin/test_formatter_tsv.rb +0 -76
  126. data/test/plugin/test_in_debug_agent.rb +0 -49
  127. data/test/plugin/test_in_exec.rb +0 -261
  128. data/test/plugin/test_in_forward.rb +0 -1178
  129. data/test/plugin/test_in_gc_stat.rb +0 -62
  130. data/test/plugin/test_in_http.rb +0 -1102
  131. data/test/plugin/test_in_monitor_agent.rb +0 -922
  132. data/test/plugin/test_in_object_space.rb +0 -66
  133. data/test/plugin/test_in_sample.rb +0 -190
  134. data/test/plugin/test_in_syslog.rb +0 -505
  135. data/test/plugin/test_in_tail.rb +0 -3288
  136. data/test/plugin/test_in_tcp.rb +0 -328
  137. data/test/plugin/test_in_udp.rb +0 -296
  138. data/test/plugin/test_in_unix.rb +0 -181
  139. data/test/plugin/test_input.rb +0 -137
  140. data/test/plugin/test_metadata.rb +0 -89
  141. data/test/plugin/test_metrics.rb +0 -294
  142. data/test/plugin/test_metrics_local.rb +0 -96
  143. data/test/plugin/test_multi_output.rb +0 -204
  144. data/test/plugin/test_out_copy.rb +0 -308
  145. data/test/plugin/test_out_exec.rb +0 -312
  146. data/test/plugin/test_out_exec_filter.rb +0 -606
  147. data/test/plugin/test_out_file.rb +0 -1038
  148. data/test/plugin/test_out_forward.rb +0 -1349
  149. data/test/plugin/test_out_http.rb +0 -429
  150. data/test/plugin/test_out_null.rb +0 -105
  151. data/test/plugin/test_out_relabel.rb +0 -28
  152. data/test/plugin/test_out_roundrobin.rb +0 -146
  153. data/test/plugin/test_out_secondary_file.rb +0 -458
  154. data/test/plugin/test_out_stdout.rb +0 -205
  155. data/test/plugin/test_out_stream.rb +0 -103
  156. data/test/plugin/test_output.rb +0 -1334
  157. data/test/plugin/test_output_as_buffered.rb +0 -2024
  158. data/test/plugin/test_output_as_buffered_backup.rb +0 -363
  159. data/test/plugin/test_output_as_buffered_compress.rb +0 -179
  160. data/test/plugin/test_output_as_buffered_overflow.rb +0 -250
  161. data/test/plugin/test_output_as_buffered_retries.rb +0 -966
  162. data/test/plugin/test_output_as_buffered_secondary.rb +0 -882
  163. data/test/plugin/test_output_as_standard.rb +0 -374
  164. data/test/plugin/test_owned_by.rb +0 -35
  165. data/test/plugin/test_parser.rb +0 -399
  166. data/test/plugin/test_parser_apache.rb +0 -42
  167. data/test/plugin/test_parser_apache2.rb +0 -47
  168. data/test/plugin/test_parser_apache_error.rb +0 -45
  169. data/test/plugin/test_parser_csv.rb +0 -200
  170. data/test/plugin/test_parser_json.rb +0 -138
  171. data/test/plugin/test_parser_labeled_tsv.rb +0 -160
  172. data/test/plugin/test_parser_multiline.rb +0 -111
  173. data/test/plugin/test_parser_nginx.rb +0 -88
  174. data/test/plugin/test_parser_none.rb +0 -52
  175. data/test/plugin/test_parser_regexp.rb +0 -284
  176. data/test/plugin/test_parser_syslog.rb +0 -650
  177. data/test/plugin/test_parser_tsv.rb +0 -122
  178. data/test/plugin/test_sd_file.rb +0 -228
  179. data/test/plugin/test_sd_srv.rb +0 -230
  180. data/test/plugin/test_storage.rb +0 -167
  181. data/test/plugin/test_storage_local.rb +0 -335
  182. data/test/plugin/test_string_util.rb +0 -26
  183. data/test/plugin_helper/data/cert/cert-key.pem +0 -27
  184. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +0 -19
  185. data/test/plugin_helper/data/cert/cert-with-no-newline.pem +0 -19
  186. data/test/plugin_helper/data/cert/cert.pem +0 -19
  187. data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +0 -27
  188. data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +0 -20
  189. data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +0 -27
  190. data/test/plugin_helper/data/cert/cert_chains/cert.pem +0 -40
  191. data/test/plugin_helper/data/cert/empty.pem +0 -0
  192. data/test/plugin_helper/data/cert/generate_cert.rb +0 -125
  193. data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +0 -30
  194. data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +0 -27
  195. data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +0 -20
  196. data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +0 -20
  197. data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +0 -30
  198. data/test/plugin_helper/data/cert/with_ca/cert-key.pem +0 -27
  199. data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +0 -21
  200. data/test/plugin_helper/data/cert/with_ca/cert.pem +0 -21
  201. data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +0 -30
  202. data/test/plugin_helper/data/cert/without_ca/cert-key.pem +0 -27
  203. data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +0 -20
  204. data/test/plugin_helper/data/cert/without_ca/cert.pem +0 -20
  205. data/test/plugin_helper/http_server/test_app.rb +0 -65
  206. data/test/plugin_helper/http_server/test_route.rb +0 -32
  207. data/test/plugin_helper/service_discovery/test_manager.rb +0 -93
  208. data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +0 -21
  209. data/test/plugin_helper/test_cert_option.rb +0 -25
  210. data/test/plugin_helper/test_child_process.rb +0 -862
  211. data/test/plugin_helper/test_compat_parameters.rb +0 -358
  212. data/test/plugin_helper/test_event_emitter.rb +0 -80
  213. data/test/plugin_helper/test_event_loop.rb +0 -52
  214. data/test/plugin_helper/test_extract.rb +0 -194
  215. data/test/plugin_helper/test_formatter.rb +0 -255
  216. data/test/plugin_helper/test_http_server_helper.rb +0 -372
  217. data/test/plugin_helper/test_inject.rb +0 -561
  218. data/test/plugin_helper/test_metrics.rb +0 -137
  219. data/test/plugin_helper/test_parser.rb +0 -264
  220. data/test/plugin_helper/test_record_accessor.rb +0 -238
  221. data/test/plugin_helper/test_retry_state.rb +0 -1006
  222. data/test/plugin_helper/test_server.rb +0 -1895
  223. data/test/plugin_helper/test_service_discovery.rb +0 -165
  224. data/test/plugin_helper/test_socket.rb +0 -146
  225. data/test/plugin_helper/test_storage.rb +0 -542
  226. data/test/plugin_helper/test_thread.rb +0 -164
  227. data/test/plugin_helper/test_timer.rb +0 -130
  228. data/test/scripts/exec_script.rb +0 -32
  229. data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +0 -7
  230. data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +0 -7
  231. data/test/scripts/fluent/plugin/formatter_known.rb +0 -8
  232. data/test/scripts/fluent/plugin/out_test.rb +0 -81
  233. data/test/scripts/fluent/plugin/out_test2.rb +0 -80
  234. data/test/scripts/fluent/plugin/parser_known.rb +0 -4
  235. data/test/test_capability.rb +0 -74
  236. data/test/test_clock.rb +0 -164
  237. data/test/test_config.rb +0 -369
  238. data/test/test_configdsl.rb +0 -148
  239. data/test/test_daemonizer.rb +0 -91
  240. data/test/test_engine.rb +0 -203
  241. data/test/test_event.rb +0 -531
  242. data/test/test_event_router.rb +0 -348
  243. data/test/test_event_time.rb +0 -199
  244. data/test/test_file_wrapper.rb +0 -53
  245. data/test/test_filter.rb +0 -121
  246. data/test/test_fluent_log_event_router.rb +0 -99
  247. data/test/test_formatter.rb +0 -369
  248. data/test/test_input.rb +0 -31
  249. data/test/test_log.rb +0 -1076
  250. data/test/test_match.rb +0 -148
  251. data/test/test_mixin.rb +0 -351
  252. data/test/test_msgpack_factory.rb +0 -50
  253. data/test/test_oj_options.rb +0 -55
  254. data/test/test_output.rb +0 -278
  255. data/test/test_plugin.rb +0 -251
  256. data/test/test_plugin_classes.rb +0 -370
  257. data/test/test_plugin_helper.rb +0 -81
  258. data/test/test_plugin_id.rb +0 -119
  259. data/test/test_process.rb +0 -14
  260. data/test/test_root_agent.rb +0 -951
  261. data/test/test_static_config_analysis.rb +0 -177
  262. data/test/test_supervisor.rb +0 -821
  263. data/test/test_test_drivers.rb +0 -136
  264. data/test/test_time_formatter.rb +0 -301
  265. data/test/test_time_parser.rb +0 -362
  266. data/test/test_tls.rb +0 -65
  267. data/test/test_unique_id.rb +0 -47
  268. data/test/test_variable_store.rb +0 -65
@@ -1,181 +0,0 @@
1
- require_relative '../helper'
2
- require 'fluent/test/driver/input'
3
- require 'fluent/plugin/in_unix'
4
-
5
- class UnixInputTest < Test::Unit::TestCase
6
- def setup
7
- Fluent::Test.setup
8
- @d = nil
9
- end
10
-
11
- def teardown
12
- @d.instance_shutdown if @d
13
- end
14
-
15
- TMP_DIR = File.dirname(__FILE__) + "/../tmp/in_unix#{ENV['TEST_ENV_NUMBER']}"
16
- CONFIG = %[
17
- path #{TMP_DIR}/unix
18
- backlog 1000
19
- ]
20
-
21
- def create_driver(conf = CONFIG)
22
- Fluent::Test::Driver::Input.new(Fluent::Plugin::UnixInput).configure(conf)
23
- end
24
-
25
- def packer(*args)
26
- Fluent::MessagePackFactory.msgpack_packer(*args)
27
- end
28
-
29
- def unpacker
30
- Fluent::MessagePackFactory.msgpack_unpacker
31
- end
32
-
33
- def send_data(data)
34
- io = UNIXSocket.new("#{TMP_DIR}/unix")
35
- begin
36
- io.write data
37
- ensure
38
- io.close
39
- end
40
- end
41
-
42
- def test_configure
43
- @d = create_driver
44
- assert_equal "#{TMP_DIR}/unix", @d.instance.path
45
- assert_equal 1000, @d.instance.backlog
46
- end
47
-
48
- def test_time
49
- @d = create_driver
50
-
51
- time = Fluent::EventTime.now
52
- records = [
53
- ["tag1", 0, {"a" => 1}],
54
- ["tag2", nil, {"a" => 2}],
55
- ]
56
-
57
- @d.run(expect_records: records.length, timeout: 5) do
58
- records.each {|tag, _time, record|
59
- send_data packer.write([tag, _time, record]).to_s
60
- }
61
- end
62
-
63
- @d.events.each_with_index { |e, i|
64
- orig = records[i]
65
- assert_equal(orig[0], e[0])
66
- assert_true(time <= e[1])
67
- assert_equal(orig[2], e[2])
68
- }
69
- end
70
-
71
- def test_message
72
- @d = create_driver
73
-
74
- time = Fluent::EventTime.now
75
- records = [
76
- ["tag1", time, {"a" => 1}],
77
- ["tag2", time, {"a" => 2}],
78
- ]
79
-
80
- @d.run(expect_records: records.length, timeout: 5) do
81
- records.each {|tag, _time, record|
82
- send_data packer.write([tag, _time, record]).to_s
83
- }
84
- end
85
-
86
- assert_equal(records, @d.events)
87
- end
88
-
89
- def test_forward
90
- @d = create_driver
91
-
92
- time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
93
- records = [
94
- ["tag1", time, {"a" => 1}],
95
- ["tag1", time, {"a" => 2}]
96
- ]
97
-
98
- @d.run(expect_records: records.length, timeout: 20) do
99
- entries = []
100
- records.each {|tag, _time, record|
101
- entries << [_time, record]
102
- }
103
- send_data packer.write(["tag1", entries]).to_s
104
- end
105
- assert_equal(records, @d.events)
106
- end
107
-
108
- def test_packed_forward
109
- @d = create_driver
110
-
111
- time = Fluent::EventTime.now
112
- records = [
113
- ["tag1", time, {"a" => 1}],
114
- ["tag1", time, {"a" => 2}],
115
- ]
116
-
117
- @d.run(expect_records: records.length, timeout: 20) do
118
- entries = ''
119
- records.each {|_tag, _time, record|
120
- packer(entries).write([_time, record]).flush
121
- }
122
- send_data packer.write(["tag1", entries]).to_s
123
- end
124
- assert_equal(records, @d.events)
125
- end
126
-
127
- def test_message_json
128
- @d = create_driver
129
-
130
- time = Fluent::EventTime.now
131
- records = [
132
- ["tag1", time, {"a" => 1}],
133
- ["tag2", time, {"a" => 2}],
134
- ]
135
-
136
- @d.run(expect_records: records.length, timeout: 5) do
137
- tag, _time, record = records[0]
138
- send_data [tag, _time.to_i, record].to_json
139
- tag, _time, record = records[1]
140
- send_data [tag, _time.to_f, record].to_json
141
- end
142
-
143
- assert_equal(records, @d.events)
144
- end
145
-
146
- def test_message_with_tag
147
- @d = create_driver(CONFIG + "tag new_tag")
148
-
149
- time = Fluent::EventTime.now
150
- records = [
151
- ["tag1", time, {"a" => 1}],
152
- ["tag2", time, {"a" => 2}],
153
- ]
154
-
155
- @d.run(expect_records: records.length, timeout: 5) do
156
- records.each {|tag, _time, record|
157
- send_data packer.write([tag, _time, record]).to_s
158
- }
159
- end
160
-
161
- @d.events.each { |event|
162
- assert_equal("new_tag", event[0])
163
- }
164
- end
165
-
166
- data('string chunk' => 'broken string',
167
- 'integer chunk' => 10)
168
- def test_broken_message(data)
169
- @d = create_driver
170
- @d.run(shutdown: false, timeout: 5) do
171
- @d.instance.__send__(:on_message, data)
172
- end
173
-
174
- assert_equal 0, @d.events.size
175
-
176
- logs = @d.instance.log.logs
177
- assert_equal 1, logs.count { |line|
178
- line =~ / \[warn\]: incoming data is broken: msg=#{data.inspect}/
179
- }, "should not accept broken chunk"
180
- end
181
- end unless Fluent.windows?
@@ -1,137 +0,0 @@
1
- require_relative '../helper'
2
- require 'fluent/plugin/input'
3
- require 'flexmock/test_unit'
4
-
5
- module FluentPluginInputTest
6
- class DummyPlugin < Fluent::Plugin::Input
7
- end
8
- end
9
-
10
- class InputTest < Test::Unit::TestCase
11
- setup do
12
- Fluent::Test.setup
13
- @p = FluentPluginInputTest::DummyPlugin.new
14
- end
15
-
16
- test 'has healthy lifecycle' do
17
- assert !@p.configured?
18
- @p.configure(config_element())
19
- assert @p.configured?
20
-
21
- assert !@p.started?
22
- @p.start
23
- assert @p.start
24
-
25
- assert !@p.stopped?
26
- @p.stop
27
- assert @p.stopped?
28
-
29
- assert !@p.before_shutdown?
30
- @p.before_shutdown
31
- assert @p.before_shutdown?
32
-
33
- assert !@p.shutdown?
34
- @p.shutdown
35
- assert @p.shutdown?
36
-
37
- assert !@p.after_shutdown?
38
- @p.after_shutdown
39
- assert @p.after_shutdown?
40
-
41
- assert !@p.closed?
42
- @p.close
43
- assert @p.closed?
44
-
45
- assert !@p.terminated?
46
- @p.terminate
47
- assert @p.terminated?
48
- end
49
-
50
- test 'has plugin_id automatically generated' do
51
- assert @p.respond_to?(:plugin_id_configured?)
52
- assert @p.respond_to?(:plugin_id)
53
-
54
- @p.configure(config_element())
55
-
56
- assert !@p.plugin_id_configured?
57
- assert @p.plugin_id
58
- assert{ @p.plugin_id != 'mytest' }
59
- end
60
-
61
- test 'has plugin_id manually configured' do
62
- @p.configure(config_element('ROOT', '', {'@id' => 'mytest'}))
63
- assert @p.plugin_id_configured?
64
- assert_equal 'mytest', @p.plugin_id
65
- end
66
-
67
- test 'has plugin logger' do
68
- assert @p.respond_to?(:log)
69
- assert @p.log
70
-
71
- # default logger
72
- original_logger = @p.log
73
-
74
- @p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
75
-
76
- assert(@p.log.object_id != original_logger.object_id)
77
- assert_equal Fluent::Log::LEVEL_DEBUG, @p.log.level
78
- end
79
-
80
- test 'can load plugin helpers' do
81
- assert_nothing_raised do
82
- class FluentPluginInputTest::DummyPlugin2 < Fluent::Plugin::Input
83
- helpers :storage
84
- end
85
- end
86
- end
87
-
88
- test 'can use metrics plugins and fallback methods' do
89
- @p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
90
-
91
- %w[emit_size_metrics emit_records_metrics].each do |metric_name|
92
- assert_true @p.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
93
- end
94
-
95
- assert_equal 0, @p.emit_size
96
- assert_equal 0, @p.emit_records
97
- end
98
-
99
- test 'are not available with multi workers configuration in default' do
100
- assert_false @p.multi_workers_ready?
101
- end
102
-
103
- test 'has router and can emit into it' do
104
- assert @p.has_router?
105
-
106
- @p.configure(config_element())
107
- assert @p.router
108
-
109
- DummyRouter = Struct.new(:emits) do
110
- def emit(tag, es)
111
- self.emits << [tag, es]
112
- end
113
- end
114
- @p.router = DummyRouter.new([])
115
- @p.router.emit('mytag', [])
116
- @p.router.emit('mytag.testing', ['it is not es, but no problem for tests'])
117
-
118
- assert_equal ['mytag', []], @p.router.emits[0]
119
- assert_equal ['mytag.testing', ['it is not es, but no problem for tests']], @p.router.emits[1]
120
- end
121
-
122
- test 'has router for specified label if configured' do
123
- @p.configure(config_element())
124
- original_router = @p.router
125
-
126
- router_mock = flexmock('mytest')
127
- router_mock.should_receive(:emit).once.with('mytag.testing', ['for mock'])
128
- label_mock = flexmock('mylabel')
129
- label_mock.should_receive(:event_router).once.and_return(router_mock)
130
- Fluent::Engine.root_agent.labels['@mytest'] = label_mock
131
-
132
- @p.configure(config_element('ROOT', '', {'@label' => '@mytest'}))
133
- assert{ @p.router.object_id != original_router.object_id }
134
-
135
- @p.router.emit('mytag.testing', ['for mock'])
136
- end
137
- end
@@ -1,89 +0,0 @@
1
- require_relative '../helper'
2
- require 'fluent/plugin/buffer'
3
-
4
- class BufferMetadataTest < Test::Unit::TestCase
5
-
6
- def meta(timekey=nil, tag=nil, variables=nil)
7
- Fluent::Plugin::Buffer::Metadata.new(timekey, tag, variables)
8
- end
9
-
10
- setup do
11
- Fluent::Test.setup
12
- end
13
-
14
- sub_test_case 'about metadata' do
15
- test 'comparison of variables should be stable' do
16
- m = meta(nil, nil, nil)
17
- # different sets of keys
18
- assert_equal(-1, m.cmp_variables({}, {a: 1}))
19
- assert_equal(1, m.cmp_variables({a: 1}, {}))
20
- assert_equal(1, m.cmp_variables({c: 1}, {a: 1}))
21
- assert_equal(-1, m.cmp_variables({a: 1}, {a: 1, b: 2}))
22
- assert_equal(1, m.cmp_variables({a: 1, c: 1}, {a: 1, b: 2}))
23
- assert_equal(1, m.cmp_variables({a: 1, b: 0, c: 1}, {a: 1, b: 2}))
24
- # same set of keys
25
- assert_equal(-1, m.cmp_variables({a: 1}, {a: 2}))
26
- assert_equal(-1, m.cmp_variables({a: 1, b: 0}, {a: 1, b: 1}))
27
- assert_equal(-1, m.cmp_variables({a: 1, b: 1, c: 100}, {a: 1, b: 1, c: 200}))
28
- assert_equal(-1, m.cmp_variables({b: 1, c: 100, a: 1}, {a: 1, b: 1, c: 200})) # comparison sorts keys
29
- assert_equal(-1, m.cmp_variables({a: nil}, {a: 1}))
30
- assert_equal(-1, m.cmp_variables({a: 1, b: nil}, {a: 1, b: 1}))
31
- end
32
-
33
- test 'comparison of metadata should be stable' do
34
- n = Time.now.to_i
35
-
36
- assert_equal(0, meta(nil, nil, nil) <=> meta(nil, nil, nil))
37
- assert_equal(0, meta(n, nil, nil) <=> meta(n, nil, nil))
38
- assert_equal(0, meta(nil, "t1", nil) <=> meta(nil, "t1", nil))
39
- assert_equal(0, meta(nil, nil, {}) <=> meta(nil, nil, {}))
40
- assert_equal(0, meta(nil, nil, {a: "1"}) <=> meta(nil, nil, {a: "1"}))
41
- assert_equal(0, meta(n, nil, {}) <=> meta(n, nil, {}))
42
- assert_equal(0, meta(n, "t1", {}) <=> meta(n, "t1", {}))
43
- assert_equal(0, meta(n, "t1", {a: "x", b: 10}) <=> meta(n, "t1", {a: "x", b: 10}))
44
-
45
- # timekey is 1st comparison key
46
- assert_equal(-1, meta(n - 300, nil, nil) <=> meta(n - 270, nil, nil))
47
- assert_equal(1, meta(n + 1, "a", nil) <=> meta(n - 1, "b", nil))
48
- assert_equal(-1, meta(n - 1, nil, {a: 100}) <=> meta(n + 1, nil, {}))
49
-
50
- # tag is 2nd
51
- assert_equal(-1, meta(nil, "a", {}) <=> meta(nil, "b", {}))
52
- assert_equal(-1, meta(n, "a", {}) <=> meta(n, "b", {}))
53
- assert_equal(1, meta(nil, "x", {a: 1}) <=> meta(nil, "t", {}))
54
- assert_equal(1, meta(n, "x", {a: 1}) <=> meta(n, "t", {}))
55
- assert_equal(1, meta(nil, "x", {a: 1}) <=> meta(nil, "t", {a: 1}))
56
- assert_equal(1, meta(n, "x", {a: 1}) <=> meta(n, "t", {a: 2}))
57
- assert_equal(1, meta(n, "x", {a: 1}) <=> meta(n, "t", {a: 10, b: 1}))
58
-
59
- # variables is the last
60
- assert_equal(-1, meta(nil, nil, {}) <=> meta(nil, nil, {a: 1}))
61
- assert_equal(-1, meta(n, "t", {}) <=> meta(n, "t", {a: 1}))
62
- assert_equal(1, meta(n, "t", {a: 1}) <=> meta(n, "t", {}))
63
- assert_equal(-1, meta(n, "t", {a: 1}) <=> meta(n, "t", {a: 2}))
64
- assert_equal(-1, meta(n, "t", {a: 1}) <=> meta(n, "t", {a: 1, b: 1}))
65
- assert_equal(1, meta(nil, nil, {b: 1}) <=> meta(nil, nil, {a: 1}))
66
- assert_equal(1, meta(n, "t", {b: 1}) <=> meta(n, "t", {a: 1}))
67
- end
68
-
69
- test 'metadata can be sorted' do
70
- n = Time.now.to_i
71
- m0 = meta(nil, nil, nil)
72
- m1 = meta(n - 1, nil, nil)
73
- m2 = meta(n - 1, "a", nil)
74
- m3 = meta(n - 1, "a", {a: 1})
75
- m4 = meta(n - 1, "a", {a: 100})
76
- m5 = meta(n - 1, "a", {a: 100, b: 1})
77
- m6 = meta(n - 1, "aa", nil)
78
- m7 = meta(n - 1, "aa", {a: 1})
79
- m8 = meta(n - 1, "b", nil)
80
- m9 = meta(n, nil, nil)
81
- m10 = meta(n + 1, nil, {a: 1})
82
- expected = [m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10].freeze
83
- ary = expected.dup
84
- 100.times do
85
- assert_equal expected, ary.shuffle.sort
86
- end
87
- end
88
- end
89
- end
@@ -1,294 +0,0 @@
1
- require_relative '../helper'
2
- require 'fluent/plugin/metrics'
3
- require 'fluent/plugin/base'
4
- require 'fluent/system_config'
5
-
6
- class BareMetrics < Fluent::Plugin::Metrics
7
- Fluent::Plugin.register_metrics('bare', self)
8
-
9
- private
10
-
11
- # Just override for tests.
12
- def has_methods_for_counter?
13
- false
14
- end
15
- end
16
-
17
- class BasicCounterMetrics < Fluent::Plugin::Metrics
18
- Fluent::Plugin.register_metrics('example', self)
19
-
20
- attr_reader :data
21
-
22
- def initialize
23
- super
24
- @data = 0
25
- end
26
- def get
27
- @data
28
- end
29
- def inc
30
- @data +=1
31
- end
32
- def add(value)
33
- @data += value
34
- end
35
- def set(value)
36
- @data = value
37
- end
38
- def close
39
- @data = 0
40
- super
41
- end
42
- end
43
-
44
- class AliasedCounterMetrics < Fluent::Plugin::Metrics
45
- Fluent::Plugin.register_metrics('example', self)
46
-
47
- attr_reader :data
48
-
49
- def initialize
50
- super
51
- @data = 0
52
- end
53
- def configure(conf)
54
- super
55
- class << self
56
- alias_method :set, :set_counter
57
- end
58
- end
59
- def get
60
- @data
61
- end
62
- def inc
63
- @data +=1
64
- end
65
- def add(value)
66
- @data += value
67
- end
68
- def set_counter(value)
69
- @data = value
70
- end
71
- def close
72
- @data = 0
73
- super
74
- end
75
- end
76
-
77
- class BasicGaugeMetrics < Fluent::Plugin::Metrics
78
- Fluent::Plugin.register_metrics('example', self)
79
-
80
- attr_reader :data
81
-
82
- def initialize
83
- super
84
- @data = 0
85
- end
86
- def get
87
- @data
88
- end
89
- def inc
90
- @data +=1
91
- end
92
- def dec
93
- @data -=1
94
- end
95
- def add(value)
96
- @data += value
97
- end
98
- def sub(value)
99
- @data -= value
100
- end
101
- def set(value)
102
- @data = value
103
- end
104
- def close
105
- @data = 0
106
- super
107
- end
108
- end
109
-
110
- class AliasedGaugeMetrics < Fluent::Plugin::Metrics
111
- Fluent::Plugin.register_metrics('example', self)
112
-
113
- attr_reader :data
114
-
115
- def initialize
116
- super
117
- @data = 0
118
- end
119
- def configure(conf)
120
- super
121
- class << self
122
- alias_method :dec, :dec_gauge
123
- alias_method :set, :set_gauge
124
- alias_method :sub, :sub_gauge
125
- end
126
- end
127
- def get
128
- @data
129
- end
130
- def inc
131
- @data +=1
132
- end
133
- def dec_gauge
134
- @data -=1
135
- end
136
- def add(value)
137
- @data += value
138
- end
139
- def sub_gauge(value)
140
- @data -= value
141
- end
142
- def set_gauge(value)
143
- @data = value
144
- end
145
- def close
146
- @data = 0
147
- super
148
- end
149
- end
150
-
151
- class StorageTest < Test::Unit::TestCase
152
- sub_test_case 'BareMetrics' do
153
- setup do
154
- @m = BareMetrics.new
155
- @m.configure(config_element())
156
- end
157
-
158
- test 'is configured with plugin information and system config' do
159
- m = BareMetrics.new
160
- m.configure(config_element('metrics', '', {}))
161
-
162
- assert_false m.use_gauge_metric
163
- assert_false m.has_methods_for_counter
164
- assert_false m.has_methods_for_gauge
165
- end
166
-
167
- test 'all bare operations are not defined yet' do
168
- assert_raise NotImplementedError do
169
- @m.get
170
- end
171
- assert_raise NotImplementedError do
172
- @m.inc
173
- end
174
- assert_raise NotImplementedError do
175
- @m.dec
176
- end
177
- assert_raise NotImplementedError do
178
- @m.add(10)
179
- end
180
- assert_raise NotImplementedError do
181
- @m.sub(11)
182
- end
183
- assert_raise NotImplementedError do
184
- @m.set(123)
185
- end
186
- end
187
- end
188
-
189
- sub_test_case 'BasicCounterMetric' do
190
- setup do
191
- @m = BasicCounterMetrics.new
192
- @m.configure(config_element('metrics', '', {'@id' => '1'}))
193
- end
194
-
195
- test 'all basic counter operations work well' do
196
- assert_true @m.has_methods_for_counter
197
- assert_false @m.has_methods_for_gauge
198
-
199
- assert_equal 0, @m.get
200
- assert_equal 1, @m.inc
201
-
202
- @m.add(20)
203
- assert_equal 21, @m.get
204
- assert_raise NotImplementedError do
205
- @m.dec
206
- end
207
-
208
- @m.set(100)
209
- assert_equal 100, @m.get
210
- assert_raise NotImplementedError do
211
- @m.sub(11)
212
- end
213
- end
214
- end
215
-
216
- sub_test_case 'AliasedCounterMetric' do
217
- setup do
218
- @m = AliasedCounterMetrics.new
219
- @m.configure(config_element('metrics', '', {}))
220
- end
221
-
222
- test 'all aliased counter operations work well' do
223
- assert_true @m.has_methods_for_counter
224
- assert_false @m.has_methods_for_gauge
225
-
226
- assert_equal 0, @m.get
227
- assert_equal 1, @m.inc
228
-
229
- @m.add(20)
230
- assert_equal 21, @m.get
231
- assert_raise NotImplementedError do
232
- @m.dec
233
- end
234
-
235
- @m.set(100)
236
- assert_equal 100, @m.get
237
- assert_raise NotImplementedError do
238
- @m.sub(11)
239
- end
240
- end
241
- end
242
-
243
- sub_test_case 'BasicGaugeMetric' do
244
- setup do
245
- @m = BasicGaugeMetrics.new
246
- @m.use_gauge_metric = true
247
- @m.configure(config_element('metrics', '', {}))
248
- end
249
-
250
- test 'all basic gauge operations work well' do
251
- assert_false @m.has_methods_for_counter
252
- assert_true @m.has_methods_for_gauge
253
-
254
- assert_equal 0, @m.get
255
- assert_equal 1, @m.inc
256
-
257
- @m.add(20)
258
- assert_equal 21, @m.get
259
- @m.dec
260
- assert_equal 20, @m.get
261
-
262
- @m.set(100)
263
- assert_equal 100, @m.get
264
- @m.sub(11)
265
- assert_equal 89, @m.get
266
- end
267
- end
268
-
269
- sub_test_case 'AliasedGaugeMetric' do
270
- setup do
271
- @m = AliasedGaugeMetrics.new
272
- @m.use_gauge_metric = true
273
- @m.configure(config_element('metrics', '', {}))
274
- end
275
-
276
- test 'all aliased gauge operations work well' do
277
- assert_false @m.has_methods_for_counter
278
- assert_true @m.has_methods_for_gauge
279
-
280
- assert_equal 0, @m.get
281
- assert_equal 1, @m.inc
282
-
283
- @m.add(20)
284
- assert_equal 21, @m.get
285
- @m.dec
286
- assert_equal 20, @m.get
287
-
288
- @m.set(100)
289
- assert_equal 100, @m.get
290
- @m.sub(11)
291
- assert_equal 89, @m.get
292
- end
293
- end
294
- end