fluentd 1.13.0-x64-mingw32 → 1.14.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.yaml +69 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.yaml +38 -0
  4. data/.github/workflows/linux-test.yaml +1 -1
  5. data/.github/workflows/windows-test.yaml +4 -4
  6. data/.gitlab-ci.yml +0 -22
  7. data/CHANGELOG.md +131 -0
  8. data/README.md +2 -2
  9. data/example/v0_12_filter.conf +2 -2
  10. data/fluentd.gemspec +1 -1
  11. data/lib/fluent/command/fluentd.rb +8 -0
  12. data/lib/fluent/command/plugin_generator.rb +15 -5
  13. data/lib/fluent/compat/output.rb +9 -6
  14. data/lib/fluent/config/section.rb +5 -0
  15. data/lib/fluent/config/types.rb +15 -0
  16. data/lib/fluent/config/v1_parser.rb +3 -2
  17. data/lib/fluent/config.rb +1 -1
  18. data/lib/fluent/env.rb +2 -1
  19. data/lib/fluent/event_router.rb +28 -1
  20. data/lib/fluent/oj_options.rb +62 -0
  21. data/lib/fluent/plugin/bare_output.rb +49 -8
  22. data/lib/fluent/plugin/buffer.rb +84 -22
  23. data/lib/fluent/plugin/file_wrapper.rb +22 -0
  24. data/lib/fluent/plugin/filter.rb +35 -1
  25. data/lib/fluent/plugin/formatter.rb +1 -0
  26. data/lib/fluent/plugin/formatter_json.rb +9 -7
  27. data/lib/fluent/plugin/in_http.rb +21 -2
  28. data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
  29. data/lib/fluent/plugin/in_syslog.rb +13 -1
  30. data/lib/fluent/plugin/in_tail/position_file.rb +20 -18
  31. data/lib/fluent/plugin/in_tail.rb +45 -4
  32. data/lib/fluent/plugin/input.rb +39 -1
  33. data/lib/fluent/plugin/metrics.rb +119 -0
  34. data/lib/fluent/plugin/metrics_local.rb +96 -0
  35. data/lib/fluent/plugin/multi_output.rb +43 -6
  36. data/lib/fluent/plugin/out_forward.rb +1 -3
  37. data/lib/fluent/plugin/output.rb +74 -33
  38. data/lib/fluent/plugin/parser_json.rb +2 -3
  39. data/lib/fluent/plugin/service_discovery.rb +0 -15
  40. data/lib/fluent/plugin.rb +10 -1
  41. data/lib/fluent/plugin_helper/event_emitter.rb +8 -1
  42. data/lib/fluent/plugin_helper/http_server/router.rb +1 -1
  43. data/lib/fluent/plugin_helper/metrics.rb +129 -0
  44. data/lib/fluent/plugin_helper/server.rb +4 -2
  45. data/lib/fluent/plugin_helper.rb +1 -0
  46. data/lib/fluent/root_agent.rb +6 -0
  47. data/lib/fluent/supervisor.rb +2 -0
  48. data/lib/fluent/system_config.rb +9 -1
  49. data/lib/fluent/test/driver/storage.rb +30 -0
  50. data/lib/fluent/version.rb +1 -1
  51. data/templates/new_gem/lib/fluent/plugin/storage.rb.erb +40 -0
  52. data/templates/new_gem/test/plugin/test_storage.rb.erb +18 -0
  53. data/test/command/test_cat.rb +11 -8
  54. data/test/command/test_plugin_generator.rb +2 -1
  55. data/test/config/test_section.rb +9 -0
  56. data/test/config/test_system_config.rb +6 -0
  57. data/test/config/test_types.rb +7 -0
  58. data/test/plugin/in_tail/test_position_file.rb +48 -8
  59. data/test/plugin/test_bare_output.rb +13 -0
  60. data/test/plugin/test_buffer.rb +8 -2
  61. data/test/plugin/test_file_wrapper.rb +11 -0
  62. data/test/plugin/test_filter.rb +11 -0
  63. data/test/plugin/test_in_forward.rb +59 -83
  64. data/test/plugin/test_in_http.rb +86 -43
  65. data/test/plugin/test_in_monitor_agent.rb +214 -8
  66. data/test/plugin/test_in_syslog.rb +101 -56
  67. data/test/plugin/test_in_tail.rb +149 -48
  68. data/test/plugin/test_in_tcp.rb +45 -32
  69. data/test/plugin/test_in_udp.rb +47 -33
  70. data/test/plugin/test_input.rb +11 -0
  71. data/test/plugin/test_metrics.rb +294 -0
  72. data/test/plugin/test_metrics_local.rb +96 -0
  73. data/test/plugin/test_multi_output.rb +25 -1
  74. data/test/plugin/test_out_forward.rb +103 -89
  75. data/test/plugin/test_out_stream.rb +18 -8
  76. data/test/plugin/test_output.rb +16 -0
  77. data/test/plugin_helper/http_server/test_route.rb +1 -1
  78. data/test/plugin_helper/test_child_process.rb +1 -1
  79. data/test/plugin_helper/test_event_emitter.rb +29 -0
  80. data/test/plugin_helper/test_http_server_helper.rb +33 -26
  81. data/test/plugin_helper/test_metrics.rb +137 -0
  82. data/test/plugin_helper/test_server.rb +137 -138
  83. data/test/plugin_helper/test_socket.rb +16 -9
  84. data/test/test_event_time.rb +2 -2
  85. data/test/test_oj_options.rb +55 -0
  86. data/test/test_plugin_classes.rb +102 -0
  87. data/test/test_root_agent.rb +30 -1
  88. metadata +22 -7
  89. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
  90. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
@@ -29,7 +29,8 @@ class TestFluentPluginGenerator < Test::Unit::TestCase
29
29
  output: ["output", "out"],
30
30
  filter: ["filter", "filter"],
31
31
  parser: ["parser", "parser"],
32
- formatter: ["formatter", "formatter"])
32
+ formatter: ["formatter", "formatter"],
33
+ storage: ["storage", "storage"])
33
34
  test "generate plugin" do |(type, part)|
34
35
  generator = FluentPluginGenerator.new([type, "fake"])
35
36
  stub_git_process(generator)
@@ -1,5 +1,6 @@
1
1
  require_relative '../helper'
2
2
  require 'fluent/config/section'
3
+ require 'pp'
3
4
 
4
5
  module Fluent::Config
5
6
  class TestSection < ::Test::Unit::TestCase
@@ -176,6 +177,14 @@ module Fluent::Config
176
177
  s1 = Fluent::Config::Section.new(h1)
177
178
  assert_equal(expected, s1.respond_to?(method))
178
179
  end
180
+
181
+ test '#pretty_print' do
182
+ q = PP.new
183
+ h1 = {name: "s1", klass: "A"}
184
+ s1 = Fluent::Config::Section.new(h1)
185
+ s1.pretty_print(q)
186
+ assert_equal s1.inspect, q.output
187
+ end
179
188
  end
180
189
  end
181
190
  end
@@ -28,6 +28,8 @@ module Fluent::Config
28
28
  log_event_label: nil,
29
29
  log_event_verbose: nil,
30
30
  without_source: nil,
31
+ enable_input_metrics: nil,
32
+ enable_size_metrics: nil,
31
33
  emit_error_log_interval: nil,
32
34
  file_permission: nil,
33
35
  dir_permission: nil,
@@ -77,6 +79,8 @@ module Fluent::Config
77
79
  assert_nil(sc.emit_error_log_interval)
78
80
  assert_nil(sc.suppress_config_dump)
79
81
  assert_nil(sc.without_source)
82
+ assert_nil(sc.enable_input_metrics)
83
+ assert_nil(sc.enable_size_metrics)
80
84
  assert_nil(sc.enable_msgpack_time_support)
81
85
  assert_equal(:text, sc.log.format)
82
86
  assert_equal('%Y-%m-%d %H:%M:%S %z', sc.log.time_format)
@@ -93,6 +97,8 @@ module Fluent::Config
93
97
  'without_source' => ['without_source', true],
94
98
  'strict_config_value' => ['strict_config_value', true],
95
99
  'enable_msgpack_time_support' => ['enable_msgpack_time_support', true],
100
+ 'enable_input_metrics' => ['enable_input_metrics', true],
101
+ 'enable_size_metrics' => ['enable_size_metrics', true],
96
102
  )
97
103
  test "accepts parameters" do |(k, v)|
98
104
  conf = parse_text(<<-EOS)
@@ -180,6 +180,13 @@ class TestConfigTypes < ::Test::Unit::TestCase
180
180
  assert_equal Encoding::UTF_8, actual.encoding
181
181
  end
182
182
 
183
+ data('starts_with_semicolon' => [:conor, ':conor'],
184
+ 'simple_string' => [:conor, 'conor'],
185
+ 'empty_string' => [nil, ''])
186
+ test 'symbol' do |(expected, val)|
187
+ assert_equal Config::SYMBOL_TYPE.call(val, {}), expected
188
+ end
189
+
183
190
  data("val" => [:val, 'val'],
184
191
  "v" => [:v, 'v'],
185
192
  "value" => [:value, 'value'])
@@ -22,6 +22,10 @@ class IntailPositionFileTest < Test::Unit::TestCase
22
22
  invalidpath100000000000000000000000000000000
23
23
  unwatched\t#{UNWATCHED_STR}\t0000000000000000
24
24
  EOF
25
+ TEST_CONTENT_PATHS = {
26
+ "valid_path" => Fluent::Plugin::TailInput::TargetInfo.new("valid_path", 1),
27
+ "inode23bit" => Fluent::Plugin::TailInput::TargetInfo.new("inode23bit", 0),
28
+ }
25
29
 
26
30
  def write_data(f, content)
27
31
  f.write(content)
@@ -36,7 +40,11 @@ class IntailPositionFileTest < Test::Unit::TestCase
36
40
 
37
41
  test '.load' do
38
42
  write_data(@file, TEST_CONTENT)
39
- Fluent::Plugin::TailInput::PositionFile.load(@file, false, {}, **{logger: $log})
43
+ paths = {
44
+ "valid_path" => Fluent::Plugin::TailInput::TargetInfo.new("valid_path", 1),
45
+ "inode23bit" => Fluent::Plugin::TailInput::TargetInfo.new("inode23bit", 2),
46
+ }
47
+ Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log})
40
48
 
41
49
  @file.seek(0)
42
50
  lines = @file.readlines
@@ -48,7 +56,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
48
56
  sub_test_case '#try_compact' do
49
57
  test 'compact invalid and convert 32 bit inode value' do
50
58
  write_data(@file, TEST_CONTENT)
51
- Fluent::Plugin::TailInput::PositionFile.new(@file, false, {}, **{logger: $log}).try_compact
59
+ Fluent::Plugin::TailInput::PositionFile.new(@file, false, **{logger: $log}).try_compact
52
60
 
53
61
  @file.seek(0)
54
62
  lines = @file.readlines
@@ -62,7 +70,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
62
70
  valid_path\t0000000000000002\t0000000000000001
63
71
  valid_path\t0000000000000003\t0000000000000004
64
72
  EOF
65
- Fluent::Plugin::TailInput::PositionFile.new(@file, false, {}, **{logger: $log}).try_compact
73
+ Fluent::Plugin::TailInput::PositionFile.new(@file, false, **{logger: $log}).try_compact
66
74
 
67
75
  @file.seek(0)
68
76
  lines = @file.readlines
@@ -71,7 +79,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
71
79
 
72
80
  test 'does not change when the file is changed' do
73
81
  write_data(@file, TEST_CONTENT)
74
- pf = Fluent::Plugin::TailInput::PositionFile.new(@file, false, {}, **{logger: $log})
82
+ pf = Fluent::Plugin::TailInput::PositionFile.new(@file, false, **{logger: $log})
75
83
 
76
84
  mock.proxy(pf).fetch_compacted_entries do |r|
77
85
  @file.write("unwatched\t#{UNWATCHED_STR}\t0000000000000000\n")
@@ -86,7 +94,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
86
94
  end
87
95
 
88
96
  test 'update seek position of remained position entry' do
89
- pf = Fluent::Plugin::TailInput::PositionFile.new(@file, false, {}, **{logger: $log})
97
+ pf = Fluent::Plugin::TailInput::PositionFile.new(@file, false, **{logger: $log})
90
98
  target_info1 = Fluent::Plugin::TailInput::TargetInfo.new('path1', -1)
91
99
  target_info2 = Fluent::Plugin::TailInput::TargetInfo.new('path2', -1)
92
100
  target_info3 = Fluent::Plugin::TailInput::TargetInfo.new('path3', -1)
@@ -115,12 +123,35 @@ class IntailPositionFileTest < Test::Unit::TestCase
115
123
  assert_equal "path3\t#{UNWATCHED_STR}\t0000000000000000\n", lines[1]
116
124
  assert_equal 2, lines.size
117
125
  end
126
+
127
+ test 'should ignore initial existing files on follow_inode' do
128
+ write_data(@file, TEST_CONTENT)
129
+ pos_file = Fluent::Plugin::TailInput::PositionFile.load(@file, true, TEST_CONTENT_PATHS, **{logger: $log})
130
+ @file.seek(0)
131
+ assert_equal([], @file.readlines)
132
+
133
+ @file.seek(0)
134
+ write_data(@file, TEST_CONTENT)
135
+ pos_file.try_compact
136
+
137
+ @file.seek(0)
138
+ assert_equal([
139
+ "valid_path\t0000000000000002\t0000000000000001\n",
140
+ "inode23bit\t0000000000000000\t0000000000000000\n",
141
+ ],
142
+ @file.readlines)
143
+ end
118
144
  end
119
145
 
120
146
  sub_test_case '#load' do
121
147
  test 'compact invalid and convert 32 bit inode value' do
122
148
  write_data(@file, TEST_CONTENT)
123
- Fluent::Plugin::TailInput::PositionFile.load(@file, false, {}, **{logger: $log})
149
+ invalid_path = "invalidpath100000000000000000000000000000000"
150
+ paths = TEST_CONTENT_PATHS.merge({
151
+ invalid_path => Fluent::Plugin::TailInput::TargetInfo.new(invalid_path, 0),
152
+ "unwatched" => Fluent::Plugin::TailInput::TargetInfo.new("unwatched", 0),
153
+ })
154
+ Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log})
124
155
 
125
156
  @file.seek(0)
126
157
  lines = @file.readlines
@@ -129,12 +160,21 @@ class IntailPositionFileTest < Test::Unit::TestCase
129
160
  assert_equal "inode23bit\t0000000000000000\t0000000000000000\n", lines[1]
130
161
  end
131
162
 
163
+ test 'compact deleted paths' do
164
+ write_data(@file, TEST_CONTENT)
165
+ Fluent::Plugin::TailInput::PositionFile.load(@file, false, {}, **{logger: $log})
166
+
167
+ @file.seek(0)
168
+ lines = @file.readlines
169
+ assert_equal [], lines
170
+ end
171
+
132
172
  test 'compact data if duplicated line' do
133
173
  write_data(@file, <<~EOF)
134
174
  valid_path\t0000000000000002\t0000000000000001
135
175
  valid_path\t0000000000000003\t0000000000000004
136
176
  EOF
137
- Fluent::Plugin::TailInput::PositionFile.new(@file, false, {}, **{logger: $log}).load
177
+ Fluent::Plugin::TailInput::PositionFile.new(@file, false, **{logger: $log}).load
138
178
 
139
179
  @file.seek(0)
140
180
  lines = @file.readlines
@@ -145,7 +185,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
145
185
  sub_test_case '#[]' do
146
186
  test 'return entry' do
147
187
  write_data(@file, TEST_CONTENT)
148
- pf = Fluent::Plugin::TailInput::PositionFile.load(@file, false, {}, **{logger: $log})
188
+ pf = Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log})
149
189
 
150
190
  valid_target_info = Fluent::Plugin::TailInput::TargetInfo.new('valid_path', File.stat(@file).ino)
151
191
  f = pf[valid_target_info]
@@ -95,6 +95,19 @@ class BareOutputTest < Test::Unit::TestCase
95
95
  end
96
96
  end
97
97
 
98
+ test 'can use metrics plugins and fallback methods' do
99
+ @p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
100
+
101
+ %w[num_errors_metrics emit_count_metrics emit_size_metrics emit_records_metrics].each do |metric_name|
102
+ assert_true @p.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
103
+ end
104
+
105
+ assert_equal 0, @p.num_errors
106
+ assert_equal 0, @p.emit_count
107
+ assert_equal 0, @p.emit_size
108
+ assert_equal 0, @p.emit_records
109
+ end
110
+
98
111
  test 'can get input event stream to write' do
99
112
  @p.configure(config_element('ROOT'))
100
113
  @p.start
@@ -238,8 +238,14 @@ class BufferTest < Test::Unit::TestCase
238
238
  assert_nil @p.queue
239
239
  assert_nil @p.dequeued
240
240
  assert_nil @p.queued_num
241
- assert_equal 0, @p.stage_size
242
- assert_equal 0, @p.queue_size
241
+ assert_nil @p.stage_length_metrics
242
+ assert_nil @p.stage_size_metrics
243
+ assert_nil @p.queue_length_metrics
244
+ assert_nil @p.queue_size_metrics
245
+ assert_nil @p.available_buffer_space_ratios_metrics
246
+ assert_nil @p.total_queued_size_metrics
247
+ assert_nil @p.newest_timekey_metrics
248
+ assert_nil @p.oldest_timekey_metrics
243
249
  assert_equal [], @p.timekeys
244
250
  end
245
251
 
@@ -96,6 +96,17 @@ class FileWrapperTest < Test::Unit::TestCase
96
96
  end
97
97
  end
98
98
 
99
+ test 'Errno::ENOENT raised on DeletePending' do
100
+ path = "#{TMP_DIR}/deletepending.txt"
101
+ file = Fluent::WindowsFile.new(path, mode='w')
102
+ File.delete(path)
103
+ assert_raise(Errno::ENOENT) do
104
+ file.stat
105
+ ensure
106
+ file.close if file
107
+ end
108
+ end
109
+
99
110
  test 'ERROR_SHARING_VIOLATION raised' do
100
111
  begin
101
112
  path = "#{TMP_DIR}/test_windows_file.txt"
@@ -165,6 +165,17 @@ class FilterPluginTest < Test::Unit::TestCase
165
165
  end
166
166
  end
167
167
 
168
+ test 'can use metrics plugins and fallback methods' do
169
+ @p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
170
+
171
+ %w[emit_size_metrics emit_records_metrics].each do |metric_name|
172
+ assert_true @p.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
173
+ end
174
+
175
+ assert_equal 0, @p.emit_size
176
+ assert_equal 0, @p.emit_records
177
+ end
178
+
168
179
  test 'are available with multi worker configuration in default' do
169
180
  assert @p.multi_workers_ready?
170
181
  end
@@ -18,52 +18,55 @@ class ForwardInputTest < Test::Unit::TestCase
18
18
  Fluent::Test.setup
19
19
  @responses = [] # for testing responses after sending data
20
20
  @d = nil
21
+ @port = unused_port
21
22
  end
22
23
 
23
24
  def teardown
24
25
  @d.instance_shutdown if @d
26
+ @port = nil
25
27
  end
26
28
 
27
- PORT = unused_port
28
-
29
29
  SHARED_KEY = 'foobar1'
30
30
  USER_NAME = 'tagomoris'
31
31
  USER_PASSWORD = 'fluentd'
32
32
 
33
- CONFIG = %[
34
- port #{PORT}
35
- bind 127.0.0.1
36
- ]
33
+ def base_config
34
+ %[
35
+ port #{@port}
36
+ bind 127.0.0.1
37
+ ]
38
+ end
37
39
  LOCALHOST_HOSTNAME_GETTER = ->(){sock = UDPSocket.new(::Socket::AF_INET); sock.do_not_reverse_lookup = false; sock.connect("127.0.0.1", 2048); sock.peeraddr[2] }
38
40
  LOCALHOST_HOSTNAME = LOCALHOST_HOSTNAME_GETTER.call
39
41
  DUMMY_SOCK = Struct.new(:remote_host, :remote_addr, :remote_port).new(LOCALHOST_HOSTNAME, "127.0.0.1", 0)
40
- CONFIG_AUTH = %[
41
- port #{PORT}
42
- bind 127.0.0.1
43
- <security>
44
- self_hostname localhost
45
- shared_key foobar1
46
- user_auth true
47
- <user>
48
- username #{USER_NAME}
49
- password #{USER_PASSWORD}
50
- </user>
51
- <client>
52
- network 127.0.0.0/8
53
- shared_key #{SHARED_KEY}
54
- users ["#{USER_NAME}"]
55
- </client>
56
- </security>
57
- ]
58
-
59
- def create_driver(conf=CONFIG)
42
+
43
+ def config_auth
44
+ base_config + %[
45
+ <security>
46
+ self_hostname localhost
47
+ shared_key foobar1
48
+ user_auth true
49
+ <user>
50
+ username #{USER_NAME}
51
+ password #{USER_PASSWORD}
52
+ </user>
53
+ <client>
54
+ network 127.0.0.0/8
55
+ shared_key #{SHARED_KEY}
56
+ users ["#{USER_NAME}"]
57
+ </client>
58
+ </security>
59
+ ]
60
+ end
61
+
62
+ def create_driver(conf=base_config)
60
63
  Fluent::Test::Driver::Input.new(Fluent::Plugin::ForwardInput).configure(conf)
61
64
  end
62
65
 
63
66
  sub_test_case '#configure' do
64
67
  test 'simple' do
65
68
  @d = d = create_driver
66
- assert_equal PORT, d.instance.port
69
+ assert_equal @port, d.instance.port
67
70
  assert_equal '127.0.0.1', d.instance.bind
68
71
  assert_equal 0, d.instance.linger_timeout
69
72
  assert_equal 0.5, d.instance.blocking_timeout
@@ -71,8 +74,8 @@ class ForwardInputTest < Test::Unit::TestCase
71
74
  end
72
75
 
73
76
  test 'auth' do
74
- @d = d = create_driver(CONFIG_AUTH)
75
- assert_equal PORT, d.instance.port
77
+ @d = d = create_driver(config_auth)
78
+ assert_equal @port, d.instance.port
76
79
  assert_equal '127.0.0.1', d.instance.bind
77
80
  assert_equal 0, d.instance.linger_timeout
78
81
  assert !d.instance.backlog
@@ -86,17 +89,17 @@ class ForwardInputTest < Test::Unit::TestCase
86
89
  add_tag_prefix: "add_tag_prefix")
87
90
  test 'tag parameters' do |data|
88
91
  assert_raise(Fluent::ConfigError.new("'#{data}' parameter must not be empty")) {
89
- create_driver(CONFIG + "#{data} ''")
92
+ create_driver(base_config + "#{data} ''")
90
93
  }
91
94
  end
92
95
 
93
96
  test 'send_keepalive_packet is disabled by default' do
94
- @d = d = create_driver(CONFIG_AUTH)
97
+ @d = d = create_driver(config_auth)
95
98
  assert_false d.instance.send_keepalive_packet
96
99
  end
97
100
 
98
101
  test 'send_keepalive_packet can be enabled' do
99
- @d = d = create_driver(CONFIG_AUTH + %[
102
+ @d = d = create_driver(config_auth + %[
100
103
  send_keepalive_packet true
101
104
  ])
102
105
  assert_true d.instance.send_keepalive_packet
@@ -104,7 +107,7 @@ class ForwardInputTest < Test::Unit::TestCase
104
107
 
105
108
  test 'both send_keepalive_packet and deny_keepalive cannot be enabled' do
106
109
  assert_raise(Fluent::ConfigError.new("both 'send_keepalive_packet' and 'deny_keepalive' cannot be set to true")) do
107
- create_driver(CONFIG_AUTH + %[
110
+ create_driver(config_auth + %[
108
111
  send_keepalive_packet true
109
112
  deny_keepalive true
110
113
  ])
@@ -173,7 +176,7 @@ class ForwardInputTest < Test::Unit::TestCase
173
176
  end
174
177
 
175
178
  test 'skip_invalid_event' do
176
- @d = d = create_driver(CONFIG + "skip_invalid_event true")
179
+ @d = d = create_driver(base_config + "skip_invalid_event true")
177
180
 
178
181
  time = event_time("2011-01-02 13:14:15 UTC")
179
182
 
@@ -243,20 +246,18 @@ class ForwardInputTest < Test::Unit::TestCase
243
246
 
244
247
  sub_test_case 'forward' do
245
248
  data(tcp: {
246
- config: CONFIG,
247
249
  options: {
248
250
  auth: false
249
251
  }
250
252
  },
251
253
  auth: {
252
- config: CONFIG_AUTH,
253
254
  options: {
254
255
  auth: true
255
256
  }
256
257
  })
257
258
  test 'plain' do |data|
258
- config = data[:config]
259
259
  options = data[:options]
260
+ config = options[:auth] ? config_auth : base_config
260
261
  @d = d = create_driver(config)
261
262
 
262
263
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -285,7 +286,7 @@ class ForwardInputTest < Test::Unit::TestCase
285
286
  result: "new_prefix.tag1"
286
287
  })
287
288
  test 'tag parameters' do |data|
288
- @d = create_driver(CONFIG + data[:param])
289
+ @d = create_driver(base_config + data[:param])
289
290
  time = event_time("2011-01-02 13:14:15 UTC")
290
291
  options = {auth: false}
291
292
 
@@ -305,20 +306,18 @@ class ForwardInputTest < Test::Unit::TestCase
305
306
  end
306
307
 
307
308
  data(tcp: {
308
- config: CONFIG,
309
309
  options: {
310
310
  auth: false
311
311
  }
312
312
  },
313
313
  auth: {
314
- config: CONFIG_AUTH,
315
314
  options: {
316
315
  auth: true
317
316
  }
318
317
  })
319
318
  test 'time_as_integer' do |data|
320
- config = data[:config]
321
319
  options = data[:options]
320
+ config = options[:auth] ? config_auth : base_config
322
321
  @d = d = create_driver(config)
323
322
 
324
323
  time_i = event_time("2011-01-02 13:14:15 UTC")
@@ -340,20 +339,18 @@ class ForwardInputTest < Test::Unit::TestCase
340
339
  end
341
340
 
342
341
  data(tcp: {
343
- config: CONFIG,
344
342
  options: {
345
343
  auth: false
346
344
  }
347
345
  },
348
346
  auth: {
349
- config: CONFIG_AUTH,
350
347
  options: {
351
348
  auth: true
352
349
  }
353
350
  })
354
351
  test 'skip_invalid_event' do |data|
355
- config = data[:config]
356
352
  options = data[:options]
353
+ config = options[:auth] ? config_auth : base_config
357
354
  @d = d = create_driver(config + "skip_invalid_event true")
358
355
 
359
356
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -380,20 +377,18 @@ class ForwardInputTest < Test::Unit::TestCase
380
377
 
381
378
  sub_test_case 'packed forward' do
382
379
  data(tcp: {
383
- config: CONFIG,
384
380
  options: {
385
381
  auth: false
386
382
  }
387
383
  },
388
384
  auth: {
389
- config: CONFIG_AUTH,
390
385
  options: {
391
386
  auth: true
392
387
  }
393
388
  })
394
389
  test 'plain' do |data|
395
- config = data[:config]
396
390
  options = data[:options]
391
+ config = options[:auth] ? config_auth : base_config
397
392
  @d = d = create_driver(config)
398
393
 
399
394
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -422,7 +417,7 @@ class ForwardInputTest < Test::Unit::TestCase
422
417
  result: "new_prefix.tag1"
423
418
  })
424
419
  test 'tag parameters' do |data|
425
- @d = create_driver(CONFIG + data[:param])
420
+ @d = create_driver(base_config + data[:param])
426
421
  time = event_time("2011-01-02 13:14:15 UTC")
427
422
  options = {auth: false}
428
423
 
@@ -442,20 +437,18 @@ class ForwardInputTest < Test::Unit::TestCase
442
437
  end
443
438
 
444
439
  data(tcp: {
445
- config: CONFIG,
446
440
  options: {
447
441
  auth: false
448
442
  }
449
443
  },
450
444
  auth: {
451
- config: CONFIG_AUTH,
452
445
  options: {
453
446
  auth: true
454
447
  }
455
448
  })
456
449
  test 'time_as_integer' do |data|
457
- config = data[:config]
458
450
  options = data[:options]
451
+ config = options[:auth] ? config_auth : base_config
459
452
  @d = d = create_driver(config)
460
453
 
461
454
  time_i = event_time("2011-01-02 13:14:15 UTC").to_i
@@ -476,20 +469,18 @@ class ForwardInputTest < Test::Unit::TestCase
476
469
  end
477
470
 
478
471
  data(tcp: {
479
- config: CONFIG,
480
472
  options: {
481
473
  auth: false
482
474
  }
483
475
  },
484
476
  auth: {
485
- config: CONFIG_AUTH,
486
477
  options: {
487
478
  auth: true
488
479
  }
489
480
  })
490
481
  test 'skip_invalid_event' do |data|
491
- config = data[:config]
492
482
  options = data[:options]
483
+ config = options[:auth] ? config_auth : base_config
493
484
  @d = d = create_driver(config + "skip_invalid_event true")
494
485
 
495
486
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -577,7 +568,7 @@ class ForwardInputTest < Test::Unit::TestCase
577
568
 
578
569
  sub_test_case 'warning' do
579
570
  test 'send_large_chunk_warning' do
580
- @d = d = create_driver(CONFIG + %[
571
+ @d = d = create_driver(base_config + %[
581
572
  chunk_size_warn_limit 16M
582
573
  chunk_size_limit 32M
583
574
  ])
@@ -613,7 +604,7 @@ class ForwardInputTest < Test::Unit::TestCase
613
604
  end
614
605
 
615
606
  test 'send_large_chunk_only_warning' do
616
- @d = d = create_driver(CONFIG + %[
607
+ @d = d = create_driver(base_config + %[
617
608
  chunk_size_warn_limit 16M
618
609
  ])
619
610
  time = event_time("2014-04-25 13:14:15 UTC")
@@ -639,7 +630,7 @@ class ForwardInputTest < Test::Unit::TestCase
639
630
  end
640
631
 
641
632
  test 'send_large_chunk_limit' do
642
- @d = d = create_driver(CONFIG + %[
633
+ @d = d = create_driver(base_config + %[
643
634
  chunk_size_warn_limit 16M
644
635
  chunk_size_limit 32M
645
636
  ])
@@ -697,20 +688,18 @@ class ForwardInputTest < Test::Unit::TestCase
697
688
 
698
689
  sub_test_case 'respond to required ack' do
699
690
  data(tcp: {
700
- config: CONFIG,
701
691
  options: {
702
692
  auth: false
703
693
  }
704
694
  },
705
695
  auth: {
706
- config: CONFIG_AUTH,
707
696
  options: {
708
697
  auth: true
709
698
  }
710
699
  })
711
700
  test 'message' do |data|
712
- config = data[:config]
713
701
  options = data[:options]
702
+ config = options[:auth] ? config_auth : base_config
714
703
  @d = d = create_driver(config)
715
704
 
716
705
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -736,20 +725,18 @@ class ForwardInputTest < Test::Unit::TestCase
736
725
 
737
726
  # FIX: response is not pushed into @responses because IO.select has been blocked until InputForward shutdowns
738
727
  data(tcp: {
739
- config: CONFIG,
740
728
  options: {
741
729
  auth: false
742
730
  }
743
731
  },
744
732
  auth: {
745
- config: CONFIG_AUTH,
746
733
  options: {
747
734
  auth: true
748
735
  }
749
736
  })
750
737
  test 'forward' do |data|
751
- config = data[:config]
752
738
  options = data[:options]
739
+ config = options[:auth] ? config_auth : base_config
753
740
  @d = d = create_driver(config)
754
741
 
755
742
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -776,20 +763,18 @@ class ForwardInputTest < Test::Unit::TestCase
776
763
  end
777
764
 
778
765
  data(tcp: {
779
- config: CONFIG,
780
766
  options: {
781
767
  auth: false
782
768
  }
783
769
  },
784
770
  auth: {
785
- config: CONFIG_AUTH,
786
771
  options: {
787
772
  auth: true
788
773
  }
789
774
  })
790
775
  test 'packed_forward' do |data|
791
- config = data[:config]
792
776
  options = data[:options]
777
+ config = options[:auth] ? config_auth : base_config
793
778
  @d = d = create_driver(config)
794
779
 
795
780
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -817,22 +802,20 @@ class ForwardInputTest < Test::Unit::TestCase
817
802
 
818
803
  data(
819
804
  tcp: {
820
- config: CONFIG,
821
805
  options: {
822
806
  auth: false
823
807
  }
824
808
  },
825
809
  ### Auth is not supported with json
826
810
  # auth: {
827
- # config: CONFIG_AUTH,
828
811
  # options: {
829
812
  # auth: true
830
813
  # }
831
814
  # },
832
815
  )
833
816
  test 'message_json' do |data|
834
- config = data[:config]
835
817
  options = data[:options]
818
+ config = options[:auth] ? config_auth : base_config
836
819
  @d = d = create_driver(config)
837
820
 
838
821
  time_i = event_time("2011-01-02 13:14:15 UTC")
@@ -859,20 +842,18 @@ class ForwardInputTest < Test::Unit::TestCase
859
842
 
860
843
  sub_test_case 'not respond without required ack' do
861
844
  data(tcp: {
862
- config: CONFIG,
863
845
  options: {
864
846
  auth: false
865
847
  }
866
848
  },
867
849
  auth: {
868
- config: CONFIG_AUTH,
869
850
  options: {
870
851
  auth: true
871
852
  }
872
853
  })
873
854
  test 'message' do |data|
874
- config = data[:config]
875
855
  options = data[:options]
856
+ config = options[:auth] ? config_auth : base_config
876
857
  @d = d = create_driver(config)
877
858
 
878
859
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -893,20 +874,18 @@ class ForwardInputTest < Test::Unit::TestCase
893
874
  end
894
875
 
895
876
  data(tcp: {
896
- config: CONFIG,
897
877
  options: {
898
878
  auth: false
899
879
  }
900
880
  },
901
881
  auth: {
902
- config: CONFIG_AUTH,
903
882
  options: {
904
883
  auth: true
905
884
  }
906
885
  })
907
886
  test 'forward' do |data|
908
- config = data[:config]
909
887
  options = data[:options]
888
+ config = options[:auth] ? config_auth : base_config
910
889
  @d = d = create_driver(config)
911
890
 
912
891
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -929,20 +908,18 @@ class ForwardInputTest < Test::Unit::TestCase
929
908
  end
930
909
 
931
910
  data(tcp: {
932
- config: CONFIG,
933
911
  options: {
934
912
  auth: false
935
913
  }
936
914
  },
937
915
  auth: {
938
- config: CONFIG_AUTH,
939
916
  options: {
940
917
  auth: true
941
918
  }
942
919
  })
943
920
  test 'packed_forward' do |data|
944
- config = data[:config]
945
921
  options = data[:options]
922
+ config = options[:auth] ? config_auth : base_config
946
923
  @d = d = create_driver(config)
947
924
 
948
925
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -966,22 +943,21 @@ class ForwardInputTest < Test::Unit::TestCase
966
943
 
967
944
  data(
968
945
  tcp: {
969
- config: CONFIG,
970
946
  options: {
971
947
  auth: false
972
948
  }
973
949
  },
974
950
  ### Auth is not supported with json
975
951
  # auth: {
976
- # config: CONFIG_AUTH,
952
+ # config: config_auth,
977
953
  # options: {
978
954
  # auth: true
979
955
  # }
980
956
  # },
981
957
  )
982
958
  test 'message_json' do |data|
983
- config = data[:config]
984
959
  options = data[:options]
960
+ config = options[:auth] ? config_auth : base_config
985
961
  @d = d = create_driver(config)
986
962
 
987
963
  time_i = event_time("2011-01-02 13:14:15 UTC").to_i
@@ -1096,7 +1072,7 @@ class ForwardInputTest < Test::Unit::TestCase
1096
1072
  end
1097
1073
 
1098
1074
  def connect
1099
- TCPSocket.new('127.0.0.1', PORT)
1075
+ TCPSocket.new('127.0.0.1', @port)
1100
1076
  end
1101
1077
 
1102
1078
  # Data ordering is not assured:
@@ -1165,7 +1141,7 @@ class ForwardInputTest < Test::Unit::TestCase
1165
1141
  end
1166
1142
 
1167
1143
  def execute_test_with_source_hostname_key(*keys, &block)
1168
- conf = CONFIG.dup
1144
+ conf = base_config.dup
1169
1145
  if keys.include?(:hostname)
1170
1146
  conf << <<EOL
1171
1147
  source_hostname_key source_hostname