fluentd 1.13.0-x64-mingw32 → 1.13.1-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.

@@ -346,23 +346,15 @@ class TailInputTest < Test::Unit::TestCase
346
346
  end
347
347
 
348
348
  sub_test_case "reads_bytes_per_second w/o throttled" do
349
- data("flat 8192 bytes, 2 events" => [:flat, 100, 8192, 2, false],
350
- "flat 8192 bytes, 2 events already read limit reached" => [:flat, 100, 8192, 2, true],
351
- "flat 8192 bytes, 2 events w/o stat watcher" => [:flat_without_stat, 100, 8192, 2, false],
349
+ data("flat 8192 bytes, 2 events" => [:flat, 100, 8192, 2],
350
+ "flat 8192 bytes, 2 events w/o stat watcher" => [:flat_without_stat, 100, 8192, 2],
352
351
  "flat #{8192*10} bytes, 20 events" => [:flat, 100, (8192 * 10), 20],
353
352
  "flat #{8192*10} bytes, 20 events w/o stat watcher" => [:flat_without_stat, 100, (8192 * 10), 20],
354
353
  "parse #{8192*4} bytes, 8 events" => [:parse, 100, (8192 * 4), 8],
355
354
  "parse #{8192*4} bytes, 8 events w/o stat watcher" => [:parse_without_stat, 100, (8192 * 4), 8],
356
355
  "parse #{8192*10} bytes, 20 events" => [:parse, 100, (8192 * 10), 20],
357
356
  "parse #{8192*10} bytes, 20 events w/o stat watcher" => [:parse_without_stat, 100, (8192 * 10), 20],
358
- "flat 8k bytes with unit, 2 events" => [:flat, 100, "8k", 2],
359
- "flat 8k bytes with unit, 2 events w/o stat watcher" => [:flat_without_stat, 100, "8k", 2],
360
- "flat #{8*10}k bytes with unit, 20 events" => [:flat, 100, "#{8*10}k", 20],
361
- "flat #{8*10}k bytes with unit, 20 events w/o stat watcher" => [:flat_without_stat, 100, "#{8*10}k", 20],
362
- "parse #{8*4}k bytes with unit, 8 events" => [:parse, 100, "#{8*4}k", 8],
363
- "parse #{8*4}k bytes with unit, 8 events w/o stat watcher" => [:parse_without_stat, 100, "#{8*4}k", 8],
364
- "parse #{8*10}k bytes with unit, 20 events" => [:parse, 100, "#{8*10}k", 20],
365
- "parse #{8*10}k bytes with unit, 20 events w/o stat watcher" => [:parse_without_stat, 100, "#{8*10}k", 20])
357
+ "flat 8k bytes with unit, 2 events" => [:flat, 100, "8k", 2])
366
358
  def test_emit_with_read_bytes_limit_per_second(data)
367
359
  config_style, limit, limit_bytes, num_events = data
368
360
  case config_style
@@ -418,16 +410,10 @@ class TailInputTest < Test::Unit::TestCase
418
410
  end
419
411
 
420
412
  sub_test_case "reads_bytes_per_second w/ throttled already" do
421
- data("flat 8192 bytes, 2 events" => [:flat, 100, 8192, 2],
422
- "flat #{8192*10} bytes, 20 events" => [:flat, 100, (8192 * 10), 20],
423
- "parse #{8192*4} bytes, 8 events" => [:parse, 100, (8192 * 4), 8],
424
- "parse #{8192*10} bytes, 20 events" => [:parse, 100, (8192 * 10), 20],
425
- "flat 8k bytes with unit, 2 events" => [:flat, 100, "8k", 2],
426
- "flat #{8*10}k bytes with unit, 20 events" => [:flat, 100, "#{8*10}k", 20],
427
- "parse #{8*4}k bytes with unit, 8 events" => [:parse, 100, "#{8*4}k", 8],
428
- "parse #{8*10}k bytes with unit, 20 events" => [:parse, 100, "#{8*10}k", 20])
413
+ data("flat 8192 bytes" => [:flat, 100, 8192],
414
+ "parse 8192 bytes" => [:parse, 100, 8192])
429
415
  def test_emit_with_read_bytes_limit_per_second(data)
430
- config_style, limit, limit_bytes, num_events = data
416
+ config_style, limit, limit_bytes = data
431
417
  case config_style
432
418
  when :flat
433
419
  config = CONFIG_READ_FROM_HEAD + SINGLE_LINE_CONFIG + config_element("", "", { "read_lines_limit" => limit, "read_bytes_limit_per_second" => limit_bytes })
@@ -2088,6 +2074,7 @@ class TailInputTest < Test::Unit::TestCase
2088
2074
  end
2089
2075
 
2090
2076
  def test_EACCES_error_after_setup_watcher
2077
+ omit "Cannot test with root user" if Process::UID.eid == 0
2091
2078
  path = "#{TMP_DIR}/noaccess/tail.txt"
2092
2079
  begin
2093
2080
  FileUtils.mkdir_p("#{TMP_DIR}/noaccess")
@@ -2110,8 +2097,10 @@ class TailInputTest < Test::Unit::TestCase
2110
2097
  assert($log.out.logs.any?{|log| log.include?("stat() for #{path} failed with Errno::EACCES. Drop tail watcher for now.\n") })
2111
2098
  end
2112
2099
  ensure
2113
- FileUtils.chmod(0755, "#{TMP_DIR}/noaccess")
2114
- FileUtils.rm_rf("#{TMP_DIR}/noaccess")
2100
+ if File.exist?("#{TMP_DIR}/noaccess")
2101
+ FileUtils.chmod(0755, "#{TMP_DIR}/noaccess")
2102
+ FileUtils.rm_rf("#{TMP_DIR}/noaccess")
2103
+ end
2115
2104
  end unless Fluent.windows?
2116
2105
 
2117
2106
  def test_EACCES
@@ -5,21 +5,33 @@ require 'fluent/plugin/in_tcp'
5
5
  class TcpInputTest < Test::Unit::TestCase
6
6
  def setup
7
7
  Fluent::Test.setup
8
+ @port = unused_port
8
9
  end
9
10
 
10
- PORT = unused_port
11
- BASE_CONFIG = %[
12
- port #{PORT}
13
- tag tcp
14
- ]
15
- CONFIG = BASE_CONFIG + %[
16
- bind 127.0.0.1
17
- format none
18
- ]
19
- IPv6_CONFIG = BASE_CONFIG + %[
20
- bind ::1
21
- format none
22
- ]
11
+ def teardown
12
+ @port = nil
13
+ end
14
+
15
+ def base_config
16
+ %[
17
+ port #{@port}
18
+ tag tcp
19
+ ]
20
+ end
21
+
22
+ def ipv4_config
23
+ base_config + %[
24
+ bind 127.0.0.1
25
+ format none
26
+ ]
27
+ end
28
+
29
+ def ipv6_config
30
+ base_config + %[
31
+ bind ::1
32
+ format none
33
+ ]
34
+ end
23
35
 
24
36
  def create_driver(conf)
25
37
  Fluent::Test::Driver::Input.new(Fluent::Plugin::TcpInput).configure(conf)
@@ -35,22 +47,23 @@ class TcpInputTest < Test::Unit::TestCase
35
47
 
36
48
 
37
49
  data(
38
- 'ipv4' => [CONFIG, '127.0.0.1', :ipv4],
39
- 'ipv6' => [IPv6_CONFIG, '::1', :ipv6],
50
+ 'ipv4' => ['127.0.0.1', :ipv4],
51
+ 'ipv6' => ['::1', :ipv6],
40
52
  )
41
53
  test 'configure' do |data|
42
- conf, bind, protocol = data
54
+ bind, protocol = data
55
+ conf = send("#{protocol}_config")
43
56
  omit "IPv6 is not supported on this environment" if protocol == :ipv6 && !ipv6_enabled?
44
57
 
45
58
  d = create_driver(conf)
46
- assert_equal PORT, d.instance.port
59
+ assert_equal @port, d.instance.port
47
60
  assert_equal bind, d.instance.bind
48
61
  assert_equal "\n", d.instance.delimiter
49
62
  end
50
63
 
51
64
  test ' configure w/o parse section' do
52
65
  assert_raise(Fluent::ConfigError.new("<parse> section is required.")) {
53
- create_driver(BASE_CONFIG)
66
+ create_driver(base_config)
54
67
  }
55
68
  end
56
69
 
@@ -82,10 +95,10 @@ class TcpInputTest < Test::Unit::TestCase
82
95
  payloads = data['payloads']
83
96
  expecteds = data['expecteds']
84
97
 
85
- d = create_driver(BASE_CONFIG + "format #{format}")
98
+ d = create_driver(base_config + "format #{format}")
86
99
  d.run(expect_records: 2) do
87
100
  payloads.each do |payload|
88
- create_tcp_socket('127.0.0.1', PORT) do |sock|
101
+ create_tcp_socket('127.0.0.1', @port) do |sock|
89
102
  sock.send(payload, 0)
90
103
  end
91
104
  end
@@ -105,9 +118,9 @@ class TcpInputTest < Test::Unit::TestCase
105
118
  payloads = data['payloads']
106
119
  expecteds = data['expecteds']
107
120
 
108
- d = create_driver(BASE_CONFIG + "format #{format}")
121
+ d = create_driver(base_config + "format #{format}")
109
122
  d.run(expect_records: 2) do
110
- create_tcp_socket('127.0.0.1', PORT) do |sock|
123
+ create_tcp_socket('127.0.0.1', @port) do |sock|
111
124
  payloads.each do |payload|
112
125
  sock.send(payload, 0)
113
126
  end
@@ -123,13 +136,13 @@ class TcpInputTest < Test::Unit::TestCase
123
136
  end
124
137
 
125
138
  test 'source_hostname_key' do
126
- d = create_driver(BASE_CONFIG + %!
139
+ d = create_driver(base_config + %!
127
140
  format none
128
141
  source_hostname_key host
129
142
  !)
130
143
  hostname = nil
131
144
  d.run(expect_records: 1) do
132
- create_tcp_socket('127.0.0.1', PORT) do |sock|
145
+ create_tcp_socket('127.0.0.1', @port) do |sock|
133
146
  sock.do_not_reverse_lookup = false
134
147
  hostname = sock.peeraddr[2]
135
148
  sock.send("test\n", 0)
@@ -144,13 +157,13 @@ class TcpInputTest < Test::Unit::TestCase
144
157
  end
145
158
 
146
159
  test 'source_address_key' do
147
- d = create_driver(BASE_CONFIG + %!
160
+ d = create_driver(base_config + %!
148
161
  format none
149
162
  source_address_key addr
150
163
  !)
151
164
  address = nil
152
165
  d.run(expect_records: 1) do
153
- create_tcp_socket('127.0.0.1', PORT) do |sock|
166
+ create_tcp_socket('127.0.0.1', @port) do |sock|
154
167
  address = sock.peeraddr[3]
155
168
  sock.send("test\n", 0)
156
169
  end
@@ -165,7 +178,7 @@ class TcpInputTest < Test::Unit::TestCase
165
178
 
166
179
  sub_test_case '<security>' do
167
180
  test 'accept from allowed client' do
168
- d = create_driver(CONFIG + %!
181
+ d = create_driver(ipv4_config + %!
169
182
  <security>
170
183
  <client>
171
184
  network 127.0.0.1
@@ -173,7 +186,7 @@ class TcpInputTest < Test::Unit::TestCase
173
186
  </security>
174
187
  !)
175
188
  d.run(expect_records: 1) do
176
- create_tcp_socket('127.0.0.1', PORT) do |sock|
189
+ create_tcp_socket('127.0.0.1', @port) do |sock|
177
190
  sock.send("hello\n", 0)
178
191
  end
179
192
  end
@@ -185,7 +198,7 @@ class TcpInputTest < Test::Unit::TestCase
185
198
  end
186
199
 
187
200
  test 'deny from disallowed client' do
188
- d = create_driver(CONFIG + %!
201
+ d = create_driver(ipv4_config + %!
189
202
  <security>
190
203
  <client>
191
204
  network 200.0.0.0
@@ -193,7 +206,7 @@ class TcpInputTest < Test::Unit::TestCase
193
206
  </security>
194
207
  !)
195
208
  d.run(shutdown: false, expect_records: 1, timeout: 2) do
196
- create_tcp_socket('127.0.0.1', PORT) do |sock|
209
+ create_tcp_socket('127.0.0.1', @port) do |sock|
197
210
  sock.send("hello\n", 0)
198
211
  end
199
212
  end
@@ -205,7 +218,7 @@ class TcpInputTest < Test::Unit::TestCase
205
218
 
206
219
  sub_test_case '<extract>' do
207
220
  test 'extract tag from record field' do
208
- d = create_driver(BASE_CONFIG + %!
221
+ d = create_driver(base_config + %!
209
222
  <parse>
210
223
  @type json
211
224
  </parse>
@@ -214,7 +227,7 @@ class TcpInputTest < Test::Unit::TestCase
214
227
  </extract>
215
228
  !)
216
229
  d.run(expect_records: 1) do
217
- create_tcp_socket('127.0.0.1', PORT) do |sock|
230
+ create_tcp_socket('127.0.0.1', @port) do |sock|
218
231
  data = {'msg' => 'hello', 'tag' => 'helper_test'}
219
232
  sock.send("#{data.to_json}\n", 0)
220
233
  end
@@ -5,21 +5,33 @@ require 'fluent/plugin/in_udp'
5
5
  class UdpInputTest < Test::Unit::TestCase
6
6
  def setup
7
7
  Fluent::Test.setup
8
+ @port = unused_port
8
9
  end
9
10
 
10
- PORT = unused_port
11
- BASE_CONFIG = %[
12
- port #{PORT}
13
- tag udp
14
- ]
15
- CONFIG = BASE_CONFIG + %!
16
- bind 127.0.0.1
17
- format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
18
- !
19
- IPv6_CONFIG = BASE_CONFIG + %!
20
- bind ::1
21
- format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
22
- !
11
+ def teardown
12
+ @port = nil
13
+ end
14
+
15
+ def base_config
16
+ %[
17
+ port #{@port}
18
+ tag udp
19
+ ]
20
+ end
21
+
22
+ def ipv4_config
23
+ base_config + %!
24
+ bind 127.0.0.1
25
+ format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
26
+ !
27
+ end
28
+
29
+ def ipv6_config
30
+ base_config + %!
31
+ bind ::1
32
+ format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
33
+ !
34
+ end
23
35
 
24
36
  def create_driver(conf)
25
37
  Fluent::Test::Driver::Input.new(Fluent::Plugin::UdpInput).configure(conf)
@@ -45,15 +57,16 @@ class UdpInputTest < Test::Unit::TestCase
45
57
  end
46
58
 
47
59
  data(
48
- 'ipv4' => [CONFIG, '127.0.0.1', :ipv4],
49
- 'ipv6' => [IPv6_CONFIG, '::1', :ipv6],
60
+ 'ipv4' => ['127.0.0.1', :ipv4],
61
+ 'ipv6' => ['::1', :ipv6],
50
62
  )
51
63
  test 'configure' do |data|
52
- conf, bind, protocol = data
64
+ bind, protocol = data
65
+ conf = send("#{protocol}_config")
53
66
  omit "IPv6 is not supported on this environment" if protocol == :ipv6 && !ipv6_enabled?
54
67
 
55
68
  d = create_driver(conf)
56
- assert_equal PORT, d.instance.port
69
+ assert_equal @port, d.instance.port
57
70
  assert_equal bind, d.instance.bind
58
71
  assert_equal 4096, d.instance.message_length_limit
59
72
  assert_equal nil, d.instance.receive_buffer_size
@@ -61,16 +74,17 @@ class UdpInputTest < Test::Unit::TestCase
61
74
 
62
75
  test ' configure w/o parse section' do
63
76
  assert_raise(Fluent::ConfigError.new("<parse> section is required.")) {
64
- create_driver(BASE_CONFIG)
77
+ create_driver(base_config)
65
78
  }
66
79
  end
67
80
 
68
81
  data(
69
- 'ipv4' => [CONFIG, '127.0.0.1', :ipv4],
70
- 'ipv6' => [IPv6_CONFIG, '::1', :ipv6],
82
+ 'ipv4' => ['127.0.0.1', :ipv4],
83
+ 'ipv6' => ['::1', :ipv6],
71
84
  )
72
85
  test 'time_format' do |data|
73
- conf, bind, protocol = data
86
+ bind, protocol = data
87
+ conf = send("#{protocol}_config")
74
88
  omit "IPv6 is not supported on this environment" if protocol == :ipv6 && !ipv6_enabled?
75
89
 
76
90
  d = create_driver(conf)
@@ -81,7 +95,7 @@ class UdpInputTest < Test::Unit::TestCase
81
95
  ]
82
96
 
83
97
  d.run(expect_records: 2) do
84
- create_udp_socket(bind, PORT) do |u|
98
+ create_udp_socket(bind, @port) do |u|
85
99
  tests.each do |test|
86
100
  u.send(test['msg'], 0)
87
101
  end
@@ -100,7 +114,7 @@ class UdpInputTest < Test::Unit::TestCase
100
114
  )
101
115
  test 'message_length_limit/body_size_limit compatibility' do |param|
102
116
 
103
- d = create_driver(CONFIG + param)
117
+ d = create_driver(ipv4_config + param)
104
118
  assert_equal 2048, d.instance.message_length_limit
105
119
  end
106
120
 
@@ -141,9 +155,9 @@ class UdpInputTest < Test::Unit::TestCase
141
155
  payloads = data['payloads']
142
156
  expecteds = data['expecteds']
143
157
 
144
- d = create_driver(BASE_CONFIG + "format #{format}")
158
+ d = create_driver(base_config + "format #{format}")
145
159
  d.run(expect_records: 2) do
146
- create_udp_socket('127.0.0.1', PORT) do |u|
160
+ create_udp_socket('127.0.0.1', @port) do |u|
147
161
  payloads.each do |payload|
148
162
  u.send(payload, 0)
149
163
  end
@@ -159,13 +173,13 @@ class UdpInputTest < Test::Unit::TestCase
159
173
  end
160
174
 
161
175
  test 'remove_newline' do
162
- d = create_driver(BASE_CONFIG + %!
176
+ d = create_driver(base_config + %!
163
177
  format none
164
178
  remove_newline false
165
179
  !)
166
180
  payloads = ["test1\n", "test2\n"]
167
181
  d.run(expect_records: 2) do
168
- create_udp_socket('127.0.0.1', PORT) do |u|
182
+ create_udp_socket('127.0.0.1', @port) do |u|
169
183
  payloads.each do |payload|
170
184
  u.send(payload, 0)
171
185
  end
@@ -182,13 +196,13 @@ class UdpInputTest < Test::Unit::TestCase
182
196
  end
183
197
 
184
198
  test 'source_hostname_key' do
185
- d = create_driver(BASE_CONFIG + %!
199
+ d = create_driver(base_config + %!
186
200
  format none
187
201
  source_hostname_key host
188
202
  !)
189
203
  hostname = nil
190
204
  d.run(expect_records: 1) do
191
- create_udp_socket('127.0.0.1', PORT) do |u|
205
+ create_udp_socket('127.0.0.1', @port) do |u|
192
206
  u.send("test", 0)
193
207
  hostname = u.peeraddr[2]
194
208
  end
@@ -201,13 +215,13 @@ class UdpInputTest < Test::Unit::TestCase
201
215
  end
202
216
 
203
217
  test 'source_address_key' do
204
- d = create_driver(BASE_CONFIG + %!
218
+ d = create_driver(base_config + %!
205
219
  format none
206
220
  source_address_key addr
207
221
  !)
208
222
  address = nil
209
223
  d.run(expect_records: 1) do
210
- create_udp_socket('127.0.0.1', PORT) do |u|
224
+ create_udp_socket('127.0.0.1', @port) do |u|
211
225
  u.send("test", 0)
212
226
  address = u.peeraddr[3]
213
227
  end
@@ -223,7 +237,7 @@ class UdpInputTest < Test::Unit::TestCase
223
237
  # doesn't check exact value because it depends on platform and condition
224
238
 
225
239
  # check if default socket and in_udp's one without receive_buffer_size have same size buffer
226
- d0 = create_driver(BASE_CONFIG + %!
240
+ d0 = create_driver(base_config + %!
227
241
  format none
228
242
  !)
229
243
  d0.run do
@@ -237,7 +251,7 @@ class UdpInputTest < Test::Unit::TestCase
237
251
  end
238
252
 
239
253
  # check if default socket and in_udp's one with receive_buffer_size have different size buffer
240
- d1 = create_driver(BASE_CONFIG + %!
254
+ d1 = create_driver(base_config + %!
241
255
  format none
242
256
  receive_buffer_size 1001
243
257
  !)
@@ -12,32 +12,38 @@ class ForwardOutputTest < Test::Unit::TestCase
12
12
  FileUtils.rm_rf(TMP_DIR)
13
13
  FileUtils.mkdir_p(TMP_DIR)
14
14
  @d = nil
15
+ @target_port = unused_port
15
16
  end
16
17
 
17
18
  def teardown
18
19
  @d.instance_shutdown if @d
20
+ @port = nil
19
21
  end
20
22
 
21
23
  TMP_DIR = File.join(__dir__, "../tmp/out_forward#{ENV['TEST_ENV_NUMBER']}")
22
24
 
23
25
  TARGET_HOST = '127.0.0.1'
24
- TARGET_PORT = unused_port
25
- CONFIG = %[
26
- send_timeout 51
27
- heartbeat_type udp
28
- <server>
29
- name test
30
- host #{TARGET_HOST}
31
- port #{TARGET_PORT}
32
- </server>
33
- ]
34
26
 
35
- TARGET_CONFIG = %[
36
- port #{TARGET_PORT}
37
- bind #{TARGET_HOST}
38
- ]
27
+ def config
28
+ %[
29
+ send_timeout 51
30
+ heartbeat_type udp
31
+ <server>
32
+ name test
33
+ host #{TARGET_HOST}
34
+ port #{@target_port}
35
+ </server>
36
+ ]
37
+ end
38
+
39
+ def target_config
40
+ %[
41
+ port #{@target_port}
42
+ bind #{TARGET_HOST}
43
+ ]
44
+ end
39
45
 
40
- def create_driver(conf=CONFIG)
46
+ def create_driver(conf=config)
41
47
  Fluent::Test::Driver::Output.new(Fluent::Plugin::ForwardOutput) {
42
48
  attr_reader :sent_chunk_ids, :ack_handler, :discovery_manager
43
49
 
@@ -60,7 +66,7 @@ class ForwardOutputTest < Test::Unit::TestCase
60
66
  <server>
61
67
  name test
62
68
  host #{TARGET_HOST}
63
- port #{TARGET_PORT}
69
+ port #{@target_port}
64
70
  </server>
65
71
  ])
66
72
  nodes = d.instance.nodes
@@ -71,7 +77,7 @@ class ForwardOutputTest < Test::Unit::TestCase
71
77
  node = nodes.first
72
78
  assert_equal "test", node.name
73
79
  assert_equal '127.0.0.1', node.host
74
- assert_equal TARGET_PORT, node.port
80
+ assert_equal @target_port, node.port
75
81
  end
76
82
 
77
83
  test 'configure_traditional' do
@@ -80,7 +86,7 @@ class ForwardOutputTest < Test::Unit::TestCase
80
86
  <server>
81
87
  name test
82
88
  host #{TARGET_HOST}
83
- port #{TARGET_PORT}
89
+ port #{@target_port}
84
90
  </server>
85
91
  buffer_chunk_limit 10m
86
92
  EOL
@@ -100,7 +106,7 @@ EOL
100
106
  ack_response_timeout 20
101
107
  <server>
102
108
  host #{TARGET_HOST}
103
- port #{TARGET_PORT}
109
+ port #{@target_port}
104
110
  </server>
105
111
  ])
106
112
  assert_equal 30, d.instance.send_timeout
@@ -110,33 +116,33 @@ EOL
110
116
  end
111
117
 
112
118
  test 'configure_udp_heartbeat' do
113
- @d = d = create_driver(CONFIG + "\nheartbeat_type udp")
119
+ @d = d = create_driver(config + "\nheartbeat_type udp")
114
120
  assert_equal :udp, d.instance.heartbeat_type
115
121
  end
116
122
 
117
123
  test 'configure_none_heartbeat' do
118
- @d = d = create_driver(CONFIG + "\nheartbeat_type none")
124
+ @d = d = create_driver(config + "\nheartbeat_type none")
119
125
  assert_equal :none, d.instance.heartbeat_type
120
126
  end
121
127
 
122
128
  test 'configure_expire_dns_cache' do
123
- @d = d = create_driver(CONFIG + "\nexpire_dns_cache 5")
129
+ @d = d = create_driver(config + "\nexpire_dns_cache 5")
124
130
  assert_equal 5, d.instance.expire_dns_cache
125
131
  end
126
132
 
127
133
  test 'configure_dns_round_robin udp' do
128
134
  assert_raise(Fluent::ConfigError) do
129
- create_driver(CONFIG + "\nheartbeat_type udp\ndns_round_robin true")
135
+ create_driver(config + "\nheartbeat_type udp\ndns_round_robin true")
130
136
  end
131
137
  end
132
138
 
133
139
  test 'configure_dns_round_robin transport' do
134
- @d = d = create_driver(CONFIG + "\nheartbeat_type transport\ndns_round_robin true")
140
+ @d = d = create_driver(config + "\nheartbeat_type transport\ndns_round_robin true")
135
141
  assert_equal true, d.instance.dns_round_robin
136
142
  end
137
143
 
138
144
  test 'configure_dns_round_robin none' do
139
- @d = d = create_driver(CONFIG + "\nheartbeat_type none\ndns_round_robin true")
145
+ @d = d = create_driver(config + "\nheartbeat_type none\ndns_round_robin true")
140
146
  assert_equal true, d.instance.dns_round_robin
141
147
  end
142
148
 
@@ -176,7 +182,7 @@ EOL
176
182
  #{param} #{dummy_cert_path}
177
183
  <server>
178
184
  host #{TARGET_HOST}
179
- port #{TARGET_PORT}
185
+ port #{@target_port}
180
186
  </server>
181
187
  ]
182
188
 
@@ -195,7 +201,7 @@ EOL
195
201
  tls_cert_thumbprint a909502dd82ae41433e6f83886b00d4277a32a7b
196
202
  <server>
197
203
  host #{TARGET_HOST}
198
- port #{TARGET_PORT}
204
+ port #{@target_port}
199
205
  </server>
200
206
  ]
201
207
 
@@ -210,7 +216,7 @@ EOL
210
216
  transport tls
211
217
  <server>
212
218
  host #{TARGET_HOST}
213
- port #{TARGET_PORT}
219
+ port #{@target_port}
214
220
  </server>
215
221
  ]
216
222
 
@@ -232,7 +238,7 @@ EOL
232
238
  tls_cert_logical_store_name Root
233
239
  <server>
234
240
  host #{TARGET_HOST}
235
- port #{TARGET_PORT}
241
+ port #{@target_port}
236
242
  </server>
237
243
  ]
238
244
 
@@ -250,7 +256,7 @@ EOL
250
256
  tls_cert_thumbprint a909502dd82ae41433e6f83886b00d4277a32a7b
251
257
  <server>
252
258
  host #{TARGET_HOST}
253
- port #{TARGET_PORT}
259
+ port #{@target_port}
254
260
  </server>
255
261
  ]
256
262
 
@@ -321,7 +327,7 @@ EOL
321
327
  end
322
328
 
323
329
  test 'set_compress_is_gzip' do
324
- @d = d = create_driver(CONFIG + %[compress gzip])
330
+ @d = d = create_driver(config + %[compress gzip])
325
331
  assert_equal :gzip, d.instance.compress
326
332
  assert_equal :gzip, d.instance.buffer.compress
327
333
 
@@ -333,7 +339,7 @@ EOL
333
339
  mock = flexmock($log)
334
340
  mock.should_receive(:log).with("buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in <match>")
335
341
 
336
- @d = d = create_driver(CONFIG + %[
342
+ @d = d = create_driver(config + %[
337
343
  <buffer>
338
344
  type memory
339
345
  compress gzip
@@ -347,7 +353,7 @@ EOL
347
353
  end
348
354
 
349
355
  test 'phi_failure_detector disabled' do
350
- @d = d = create_driver(CONFIG + %[phi_failure_detector false \n phi_threshold 0])
356
+ @d = d = create_driver(config + %[phi_failure_detector false \n phi_threshold 0])
351
357
  node = d.instance.nodes.first
352
358
  stub(node.failure).phi { raise 'Should not be called' }
353
359
  node.tick
@@ -355,20 +361,20 @@ EOL
355
361
  end
356
362
 
357
363
  test 'phi_failure_detector enabled' do
358
- @d = d = create_driver(CONFIG + %[phi_failure_detector true \n phi_threshold 0])
364
+ @d = d = create_driver(config + %[phi_failure_detector true \n phi_threshold 0])
359
365
  node = d.instance.nodes.first
360
366
  node.tick
361
367
  assert_false node.available?
362
368
  end
363
369
 
364
370
  test 'require_ack_response is disabled in default' do
365
- @d = d = create_driver(CONFIG)
371
+ @d = d = create_driver(config)
366
372
  assert_equal false, d.instance.require_ack_response
367
373
  assert_equal 190, d.instance.ack_response_timeout
368
374
  end
369
375
 
370
376
  test 'require_ack_response can be enabled' do
371
- @d = d = create_driver(CONFIG + %[
377
+ @d = d = create_driver(config + %[
372
378
  require_ack_response true
373
379
  ack_response_timeout 2s
374
380
  ])
@@ -378,7 +384,7 @@ EOL
378
384
  end
379
385
 
380
386
  test 'suspend_flush is disable before before_shutdown' do
381
- @d = d = create_driver(CONFIG + %[
387
+ @d = d = create_driver(config + %[
382
388
  require_ack_response true
383
389
  ack_response_timeout 2s
384
390
  ])
@@ -387,7 +393,7 @@ EOL
387
393
  end
388
394
 
389
395
  test 'suspend_flush should be enabled and try_flush returns nil after before_shutdown' do
390
- @d = d = create_driver(CONFIG + %[
396
+ @d = d = create_driver(config + %[
391
397
  require_ack_response true
392
398
  ack_response_timeout 2s
393
399
  ])
@@ -398,12 +404,12 @@ EOL
398
404
  end
399
405
 
400
406
  test 'verify_connection_at_startup is disabled in default' do
401
- @d = d = create_driver(CONFIG)
407
+ @d = d = create_driver(config)
402
408
  assert_false d.instance.verify_connection_at_startup
403
409
  end
404
410
 
405
411
  test 'verify_connection_at_startup can be enabled' do
406
- @d = d = create_driver(CONFIG + %[
412
+ @d = d = create_driver(config + %[
407
413
  verify_connection_at_startup true
408
414
  ])
409
415
  assert_true d.instance.verify_connection_at_startup
@@ -412,7 +418,7 @@ EOL
412
418
  test 'send tags in str (utf-8 strings)' do
413
419
  target_input_driver = create_target_input_driver
414
420
 
415
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
421
+ @d = d = create_driver(config + %[flush_interval 1s])
416
422
 
417
423
  time = event_time("2011-01-02 13:14:15 UTC")
418
424
 
@@ -445,7 +451,7 @@ EOL
445
451
  test 'send_with_time_as_integer' do
446
452
  target_input_driver = create_target_input_driver
447
453
 
448
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
454
+ @d = d = create_driver(config + %[flush_interval 1s])
449
455
 
450
456
  time = event_time("2011-01-02 13:14:15 UTC")
451
457
 
@@ -473,7 +479,7 @@ EOL
473
479
  test 'send_without_time_as_integer' do
474
480
  target_input_driver = create_target_input_driver
475
481
 
476
- @d = d = create_driver(CONFIG + %[
482
+ @d = d = create_driver(config + %[
477
483
  flush_interval 1s
478
484
  time_as_integer false
479
485
  ])
@@ -503,7 +509,7 @@ EOL
503
509
  test 'send_comprssed_message_pack_stream_if_compress_is_gzip' do
504
510
  target_input_driver = create_target_input_driver
505
511
 
506
- @d = d = create_driver(CONFIG + %[
512
+ @d = d = create_driver(config + %[
507
513
  flush_interval 1s
508
514
  compress gzip
509
515
  ])
@@ -533,7 +539,7 @@ EOL
533
539
  test 'send_to_a_node_supporting_responses' do
534
540
  target_input_driver = create_target_input_driver
535
541
 
536
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
542
+ @d = d = create_driver(config + %[flush_interval 1s])
537
543
 
538
544
  time = event_time("2011-01-02 13:14:15 UTC")
539
545
 
@@ -559,7 +565,7 @@ EOL
559
565
  test 'send_to_a_node_not_supporting_responses' do
560
566
  target_input_driver = create_target_input_driver
561
567
 
562
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
568
+ @d = d = create_driver(config + %[flush_interval 1s])
563
569
 
564
570
  time = event_time("2011-01-02 13:14:15 UTC")
565
571
 
@@ -585,7 +591,7 @@ EOL
585
591
  test 'a node supporting responses' do
586
592
  target_input_driver = create_target_input_driver
587
593
 
588
- @d = d = create_driver(CONFIG + %[
594
+ @d = d = create_driver(config + %[
589
595
  require_ack_response true
590
596
  ack_response_timeout 1s
591
597
  <buffer tag>
@@ -633,9 +639,9 @@ EOL
633
639
  test 'a node supporting responses after stop' do
634
640
  target_input_driver = create_target_input_driver
635
641
 
636
- @d = d = create_driver(CONFIG + %[
642
+ @d = d = create_driver(config + %[
637
643
  require_ack_response true
638
- ack_response_timeout 1s
644
+ ack_response_timeout 10s
639
645
  <buffer tag>
640
646
  flush_mode immediate
641
647
  retry_type periodic
@@ -687,7 +693,7 @@ EOL
687
693
  test 'TLS transport and ack parameter combination' do |ack|
688
694
  omit "TLS and 'ack false' always fails on AppVeyor. Need to debug" if Fluent.windows? && !ack
689
695
 
690
- input_conf = TARGET_CONFIG + %[
696
+ input_conf = target_config + %[
691
697
  <transport tls>
692
698
  insecure true
693
699
  </transport>
@@ -701,7 +707,7 @@ EOL
701
707
  tls_insecure_mode true
702
708
  <server>
703
709
  host #{TARGET_HOST}
704
- port #{TARGET_PORT}
710
+ port #{@target_port}
705
711
  </server>
706
712
  <buffer>
707
713
  #flush_mode immediate
@@ -730,7 +736,7 @@ EOL
730
736
  test 'a destination node not supporting responses by just ignoring' do
731
737
  target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: false)
732
738
 
733
- @d = d = create_driver(CONFIG + %[
739
+ @d = d = create_driver(config + %[
734
740
  require_ack_response true
735
741
  ack_response_timeout 1s
736
742
  <buffer tag>
@@ -775,7 +781,7 @@ EOL
775
781
  test 'a destination node not supporting responses by disconnection' do
776
782
  target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: true)
777
783
 
778
- @d = d = create_driver(CONFIG + %[
784
+ @d = d = create_driver(config + %[
779
785
  require_ack_response true
780
786
  ack_response_timeout 1s
781
787
  <buffer tag>
@@ -818,7 +824,7 @@ EOL
818
824
  end
819
825
 
820
826
  test 'authentication_with_shared_key' do
821
- input_conf = TARGET_CONFIG + %[
827
+ input_conf = target_config + %[
822
828
  <security>
823
829
  self_hostname in.localhost
824
830
  shared_key fluentd-sharedkey
@@ -838,7 +844,7 @@ EOL
838
844
  <server>
839
845
  name test
840
846
  host #{TARGET_HOST}
841
- port #{TARGET_PORT}
847
+ port #{@target_port}
842
848
  shared_key fluentd-sharedkey
843
849
  </server>
844
850
  ]
@@ -865,7 +871,7 @@ EOL
865
871
  end
866
872
 
867
873
  test 'keepalive + shared_key' do
868
- input_conf = TARGET_CONFIG + %[
874
+ input_conf = target_config + %[
869
875
  <security>
870
876
  self_hostname in.localhost
871
877
  shared_key fluentd-sharedkey
@@ -883,7 +889,7 @@ EOL
883
889
  <server>
884
890
  name test
885
891
  host #{TARGET_HOST}
886
- port #{TARGET_PORT}
892
+ port #{@target_port}
887
893
  </server>
888
894
  ]
889
895
  @d = d = create_driver(output_conf)
@@ -913,7 +919,7 @@ EOL
913
919
  end
914
920
 
915
921
  test 'authentication_with_user_auth' do
916
- input_conf = TARGET_CONFIG + %[
922
+ input_conf = target_config + %[
917
923
  <security>
918
924
  self_hostname in.localhost
919
925
  shared_key fluentd-sharedkey
@@ -938,7 +944,7 @@ EOL
938
944
  <server>
939
945
  name test
940
946
  host #{TARGET_HOST}
941
- port #{TARGET_PORT}
947
+ port #{@target_port}
942
948
  shared_key fluentd-sharedkey
943
949
  username fluentd
944
950
  password fluentd
@@ -968,7 +974,7 @@ EOL
968
974
 
969
975
  # This test is not 100% but test failed with previous Node implementation which has race condition
970
976
  test 'Node with security is thread-safe on multi threads' do
971
- input_conf = TARGET_CONFIG + %[
977
+ input_conf = target_config + %[
972
978
  <security>
973
979
  self_hostname in.localhost
974
980
  shared_key fluentd-sharedkey
@@ -987,7 +993,7 @@ EOL
987
993
  <server>
988
994
  name test
989
995
  host #{TARGET_HOST}
990
- port #{TARGET_PORT}
996
+ port #{@target_port}
991
997
  shared_key fluentd-sharedkey
992
998
  </server>
993
999
  ]
@@ -1008,10 +1014,12 @@ EOL
1008
1014
  end
1009
1015
 
1010
1016
  logs = d.logs
1011
- assert_false(logs.any? { |log| log.include?("invalid format for PONG message") || log.include?("shared key mismatch") }, "'#{logs.last.strip}' happens")
1017
+ assert_false(logs.any? { |log|
1018
+ log.include?("invalid format for PONG message") || log.include?("shared key mismatch")
1019
+ }, "Actual log:\n#{logs.join}")
1012
1020
  end
1013
1021
 
1014
- def create_target_input_driver(response_stub: nil, disconnect: false, conf: TARGET_CONFIG)
1022
+ def create_target_input_driver(response_stub: nil, disconnect: false, conf: target_config)
1015
1023
  require 'fluent/plugin/in_forward'
1016
1024
 
1017
1025
  # TODO: Support actual TCP heartbeat test
@@ -1027,7 +1035,7 @@ EOL
1027
1035
  end
1028
1036
 
1029
1037
  test 'heartbeat_type_none' do
1030
- @d = d = create_driver(CONFIG + "\nheartbeat_type none")
1038
+ @d = d = create_driver(config + "\nheartbeat_type none")
1031
1039
  node = d.instance.nodes.first
1032
1040
  assert_equal Fluent::Plugin::ForwardOutput::NoneHeartbeatNode, node.class
1033
1041
 
@@ -1041,7 +1049,7 @@ EOL
1041
1049
  end
1042
1050
 
1043
1051
  test 'heartbeat_type_udp' do
1044
- @d = d = create_driver(CONFIG + "\nheartbeat_type udp")
1052
+ @d = d = create_driver(config + "\nheartbeat_type udp")
1045
1053
 
1046
1054
  d.instance_start
1047
1055
  usock = d.instance.instance_variable_get(:@usock)
@@ -1052,7 +1060,7 @@ EOL
1052
1060
  assert servers.find{|s| s.title == :out_forward_heartbeat_receiver }
1053
1061
  assert timers.include?(:out_forward_heartbeat_request)
1054
1062
 
1055
- mock(usock).send("\0", 0, Socket.pack_sockaddr_in(TARGET_PORT, '127.0.0.1')).once
1063
+ mock(usock).send("\0", 0, Socket.pack_sockaddr_in(@target_port, '127.0.0.1')).once
1056
1064
  d.instance.send(:on_heartbeat_timer)
1057
1065
  end
1058
1066
 
@@ -1089,7 +1097,7 @@ EOL
1089
1097
  }
1090
1098
 
1091
1099
  assert_nothing_raised do
1092
- output.configure(CONFIG + %[
1100
+ output.configure(config + %[
1093
1101
  @id unique_out_forward
1094
1102
  ])
1095
1103
  end
@@ -1097,7 +1105,7 @@ EOL
1097
1105
 
1098
1106
  sub_test_case 'verify_connection_at_startup' do
1099
1107
  test 'nodes are not available' do
1100
- @d = d = create_driver(CONFIG + %[
1108
+ @d = d = create_driver(config + %[
1101
1109
  verify_connection_at_startup true
1102
1110
  ])
1103
1111
  e = assert_raise Fluent::UnrecoverableError do
@@ -1113,7 +1121,7 @@ EOL
1113
1121
  end
1114
1122
 
1115
1123
  test 'nodes_shared_key_miss_match' do
1116
- input_conf = TARGET_CONFIG + %[
1124
+ input_conf = target_config + %[
1117
1125
  <security>
1118
1126
  self_hostname in.localhost
1119
1127
  shared_key fluentd-sharedkey
@@ -1130,7 +1138,7 @@ EOL
1130
1138
 
1131
1139
  <server>
1132
1140
  host #{TARGET_HOST}
1133
- port #{TARGET_PORT}
1141
+ port #{@target_port}
1134
1142
  </server>
1135
1143
  ]
1136
1144
  @d = d = create_driver(output_conf)
@@ -1144,7 +1152,7 @@ EOL
1144
1152
  end
1145
1153
 
1146
1154
  test 'nodes_shared_key_miss_match with TLS' do
1147
- input_conf = TARGET_CONFIG + %[
1155
+ input_conf = target_config + %[
1148
1156
  <security>
1149
1157
  self_hostname in.localhost
1150
1158
  shared_key fluentd-sharedkey
@@ -1165,7 +1173,7 @@ EOL
1165
1173
 
1166
1174
  <server>
1167
1175
  host #{TARGET_HOST}
1168
- port #{TARGET_PORT}
1176
+ port #{@target_port}
1169
1177
  </server>
1170
1178
  ]
1171
1179
  @d = d = create_driver(output_conf)
@@ -1180,7 +1188,7 @@ EOL
1180
1188
  end
1181
1189
 
1182
1190
  test 'nodes_shared_key_match' do
1183
- input_conf = TARGET_CONFIG + %[
1191
+ input_conf = target_config + %[
1184
1192
  <security>
1185
1193
  self_hostname in.localhost
1186
1194
  shared_key fluentd-sharedkey
@@ -1196,7 +1204,7 @@ EOL
1196
1204
  <server>
1197
1205
  name test
1198
1206
  host #{TARGET_HOST}
1199
- port #{TARGET_PORT}
1207
+ port #{@target_port}
1200
1208
  </server>
1201
1209
  ]
1202
1210
  @d = d = create_driver(output_conf)
@@ -1220,16 +1228,19 @@ EOL
1220
1228
  end
1221
1229
 
1222
1230
  test 'Create new connection per send_data' do
1223
- omit "Proxy of RR doesn't support kwargs of Ruby 3 yet" if RUBY_VERSION.split('.')[0].to_i >= 3
1224
-
1225
- target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1226
- output_conf = CONFIG
1231
+ target_input_driver = create_target_input_driver(conf: target_config)
1232
+ output_conf = config
1227
1233
  d = create_driver(output_conf)
1228
1234
  d.instance_start
1229
1235
 
1230
1236
  begin
1231
1237
  chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1232
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, TARGET_PORT, anything) { |sock| mock(sock).close.once; sock }.twice
1238
+ mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1239
+ linger_timeout: anything,
1240
+ send_timeout: anything,
1241
+ recv_timeout: anything,
1242
+ connect_timeout: anything
1243
+ ) { |sock| mock(sock).close.once; sock }.twice
1233
1244
 
1234
1245
  target_input_driver.run(timeout: 15) do
1235
1246
  d.run(shutdown: false) do
@@ -1251,7 +1262,7 @@ EOL
1251
1262
  name test
1252
1263
  standby
1253
1264
  host #{TARGET_HOST}
1254
- port #{TARGET_PORT}
1265
+ port #{@target_port}
1255
1266
  </server>
1256
1267
  ])
1257
1268
  d.instance_start
@@ -1260,10 +1271,8 @@ EOL
1260
1271
 
1261
1272
  sub_test_case 'keepalive' do
1262
1273
  test 'Do not create connection per send_data' do
1263
- omit "Proxy of RR doesn't support kwargs of Ruby 3 yet" if RUBY_VERSION.split('.')[0].to_i >= 3
1264
-
1265
- target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1266
- output_conf = CONFIG + %[
1274
+ target_input_driver = create_target_input_driver(conf: target_config)
1275
+ output_conf = config + %[
1267
1276
  keepalive true
1268
1277
  keepalive_timeout 2
1269
1278
  ]
@@ -1272,7 +1281,12 @@ EOL
1272
1281
 
1273
1282
  begin
1274
1283
  chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1275
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, TARGET_PORT, anything) { |sock| mock(sock).close.once; sock }.once
1284
+ mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1285
+ linger_timeout: anything,
1286
+ send_timeout: anything,
1287
+ recv_timeout: anything,
1288
+ connect_timeout: anything
1289
+ ) { |sock| mock(sock).close.once; sock }.once
1276
1290
 
1277
1291
  target_input_driver.run(timeout: 15) do
1278
1292
  d.run(shutdown: false) do
@@ -1288,7 +1302,7 @@ EOL
1288
1302
  end
1289
1303
 
1290
1304
  test 'create timer of purging obsolete sockets' do
1291
- output_conf = CONFIG + %[keepalive true]
1305
+ output_conf = config + %[keepalive true]
1292
1306
  d = create_driver(output_conf)
1293
1307
 
1294
1308
  mock(d.instance).timer_execute(:out_forward_heartbeat_request, 1).once
@@ -1298,8 +1312,8 @@ EOL
1298
1312
 
1299
1313
  sub_test_case 'with require_ack_response' do
1300
1314
  test 'Create connection per send_data' do
1301
- target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1302
- output_conf = CONFIG + %[
1315
+ target_input_driver = create_target_input_driver(conf: target_config)
1316
+ output_conf = config + %[
1303
1317
  require_ack_response true
1304
1318
  keepalive true
1305
1319
  keepalive_timeout 2
@@ -1309,7 +1323,7 @@ EOL
1309
1323
 
1310
1324
  begin
1311
1325
  chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1312
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, TARGET_PORT,
1326
+ mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1313
1327
  linger_timeout: anything,
1314
1328
  send_timeout: anything,
1315
1329
  recv_timeout: anything,