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

@@ -19,29 +19,32 @@ class HttpInputTest < Test::Unit::TestCase
19
19
 
20
20
  def setup
21
21
  Fluent::Test.setup
22
+ @port = unused_port
22
23
  end
23
24
 
24
25
  def teardown
25
26
  Timecop.return
27
+ @port = nil
26
28
  end
27
29
 
28
- PORT = unused_port
29
- CONFIG = %[
30
- port #{PORT}
31
- bind "127.0.0.1"
32
- body_size_limit 10m
33
- keepalive_timeout 5
34
- respond_with_empty_img true
35
- use_204_response false
36
- ]
37
-
38
- def create_driver(conf=CONFIG)
30
+ def config
31
+ %[
32
+ port #{@port}
33
+ bind "127.0.0.1"
34
+ body_size_limit 10m
35
+ keepalive_timeout 5
36
+ respond_with_empty_img true
37
+ use_204_response false
38
+ ]
39
+ end
40
+
41
+ def create_driver(conf=config)
39
42
  Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpInput).configure(conf)
40
43
  end
41
44
 
42
45
  def test_configure
43
46
  d = create_driver
44
- assert_equal PORT, d.instance.port
47
+ assert_equal @port, d.instance.port
45
48
  assert_equal '127.0.0.1', d.instance.bind
46
49
  assert_equal 10*1024*1024, d.instance.body_size_limit
47
50
  assert_equal 5, d.instance.keepalive_timeout
@@ -121,7 +124,7 @@ class HttpInputTest < Test::Unit::TestCase
121
124
  'msgpack' => ['msgpack', :to_msgpack])
122
125
  def test_default_with_time_format(data)
123
126
  param, method_name = data
124
- d = create_driver(CONFIG + %[
127
+ d = create_driver(config + %[
125
128
  <parse>
126
129
  keep_time_key
127
130
  time_format %iso8601
@@ -198,7 +201,7 @@ class HttpInputTest < Test::Unit::TestCase
198
201
  'msgpack' => ['msgpack', :to_msgpack])
199
202
  def test_default_multi_with_time_format(data)
200
203
  param, method_name = data
201
- d = create_driver(CONFIG + %[
204
+ d = create_driver(config + %[
202
205
  <parse>
203
206
  keep_time_key
204
207
  time_format %iso8601
@@ -222,7 +225,7 @@ class HttpInputTest < Test::Unit::TestCase
222
225
  end
223
226
 
224
227
  def test_multi_json_with_nonexistent_time_key
225
- d = create_driver(CONFIG + %[
228
+ d = create_driver(config + %[
226
229
  <parse>
227
230
  time_key missing
228
231
  </parse>
@@ -245,7 +248,7 @@ class HttpInputTest < Test::Unit::TestCase
245
248
  end
246
249
 
247
250
  def test_json_with_add_remote_addr
248
- d = create_driver(CONFIG + "add_remote_addr true")
251
+ d = create_driver(config + "add_remote_addr true")
249
252
  time = event_time("2011-01-02 13:14:15 UTC")
250
253
  time_i = time.to_i
251
254
 
@@ -267,7 +270,7 @@ class HttpInputTest < Test::Unit::TestCase
267
270
  end
268
271
 
269
272
  def test_exact_match_for_expect
270
- d = create_driver(CONFIG)
273
+ d = create_driver(config)
271
274
  records = [{ "a" => 1}, { "a" => 2 }]
272
275
  tag = "tag1"
273
276
  res_codes = []
@@ -280,7 +283,7 @@ class HttpInputTest < Test::Unit::TestCase
280
283
  end
281
284
 
282
285
  def test_exact_match_for_expect_with_other_header
283
- d = create_driver(CONFIG)
286
+ d = create_driver(config)
284
287
 
285
288
  records = [{ "a" => 1}, { "a" => 2 }]
286
289
  tag = "tag1"
@@ -299,7 +302,7 @@ class HttpInputTest < Test::Unit::TestCase
299
302
  end
300
303
 
301
304
  def test_multi_json_with_add_remote_addr
302
- d = create_driver(CONFIG + "add_remote_addr true")
305
+ d = create_driver(config + "add_remote_addr true")
303
306
  time = event_time("2011-01-02 13:14:15 UTC")
304
307
  time_i = time.to_i
305
308
 
@@ -324,7 +327,7 @@ class HttpInputTest < Test::Unit::TestCase
324
327
  end
325
328
 
326
329
  def test_json_with_add_remote_addr_given_x_forwarded_for
327
- d = create_driver(CONFIG + "add_remote_addr true")
330
+ d = create_driver(config + "add_remote_addr true")
328
331
  time = event_time("2011-01-02 13:14:15 UTC")
329
332
  time_i = time.to_i
330
333
 
@@ -352,7 +355,7 @@ class HttpInputTest < Test::Unit::TestCase
352
355
  end
353
356
 
354
357
  def test_multi_json_with_add_remote_addr_given_x_forwarded_for
355
- d = create_driver(CONFIG + "add_remote_addr true")
358
+ d = create_driver(config + "add_remote_addr true")
356
359
 
357
360
  tag = "tag1"
358
361
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -375,7 +378,7 @@ class HttpInputTest < Test::Unit::TestCase
375
378
  end
376
379
 
377
380
  def test_add_remote_addr_given_multi_x_forwarded_for
378
- d = create_driver(CONFIG + "add_remote_addr true")
381
+ d = create_driver(config + "add_remote_addr true")
379
382
 
380
383
  tag = "tag1"
381
384
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -406,7 +409,7 @@ class HttpInputTest < Test::Unit::TestCase
406
409
  end
407
410
 
408
411
  def test_multi_json_with_add_http_headers
409
- d = create_driver(CONFIG + "add_http_headers true")
412
+ d = create_driver(config + "add_http_headers true")
410
413
  time = event_time("2011-01-02 13:14:15 UTC")
411
414
  time_i = time.to_i
412
415
  records = [{"a"=>1},{"a"=>2}]
@@ -432,7 +435,7 @@ class HttpInputTest < Test::Unit::TestCase
432
435
  end
433
436
 
434
437
  def test_json_with_add_http_headers
435
- d = create_driver(CONFIG + "add_http_headers true")
438
+ d = create_driver(config + "add_http_headers true")
436
439
  time = event_time("2011-01-02 13:14:15 UTC")
437
440
  time_i = time.to_i
438
441
  events = [
@@ -462,7 +465,7 @@ class HttpInputTest < Test::Unit::TestCase
462
465
  end
463
466
 
464
467
  def test_multi_json_with_custom_parser
465
- d = create_driver(CONFIG + %[
468
+ d = create_driver(config + %[
466
469
  <parse>
467
470
  @type json
468
471
  keep_time_key true
@@ -584,7 +587,7 @@ class HttpInputTest < Test::Unit::TestCase
584
587
  end
585
588
 
586
589
  def test_with_regexp
587
- d = create_driver(CONFIG + %[
590
+ d = create_driver(config + %[
588
591
  format /^(?<field_1>\\d+):(?<field_2>\\w+)$/
589
592
  types field_1:integer
590
593
  ])
@@ -615,7 +618,7 @@ class HttpInputTest < Test::Unit::TestCase
615
618
  def test_with_csv
616
619
  require 'csv'
617
620
 
618
- d = create_driver(CONFIG + %[
621
+ d = create_driver(config + %[
619
622
  format csv
620
623
  keys foo,bar
621
624
  ])
@@ -641,7 +644,7 @@ class HttpInputTest < Test::Unit::TestCase
641
644
  end
642
645
 
643
646
  def test_response_with_empty_img
644
- d = create_driver(CONFIG)
647
+ d = create_driver(config)
645
648
  assert_equal true, d.instance.respond_with_empty_img
646
649
 
647
650
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -669,7 +672,7 @@ class HttpInputTest < Test::Unit::TestCase
669
672
  end
670
673
 
671
674
  def test_response_without_empty_img
672
- d = create_driver(CONFIG + "respond_with_empty_img false")
675
+ d = create_driver(config + "respond_with_empty_img false")
673
676
  assert_equal false, d.instance.respond_with_empty_img
674
677
 
675
678
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -695,7 +698,7 @@ class HttpInputTest < Test::Unit::TestCase
695
698
  end
696
699
 
697
700
  def test_response_use_204_response
698
- d = create_driver(CONFIG + %[
701
+ d = create_driver(config + %[
699
702
  respond_with_empty_img false
700
703
  use_204_response true
701
704
  ])
@@ -724,7 +727,7 @@ class HttpInputTest < Test::Unit::TestCase
724
727
  end
725
728
 
726
729
  def test_cors_allowed
727
- d = create_driver(CONFIG + "cors_allow_origins [\"http://foo.com\"]")
730
+ d = create_driver(config + "cors_allow_origins [\"http://foo.com\"]")
728
731
  assert_equal ["http://foo.com"], d.instance.cors_allow_origins
729
732
 
730
733
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -751,7 +754,7 @@ class HttpInputTest < Test::Unit::TestCase
751
754
  end
752
755
 
753
756
  def test_cors_allowed_wildcard
754
- d = create_driver(CONFIG + 'cors_allow_origins ["*"]')
757
+ d = create_driver(config + 'cors_allow_origins ["*"]')
755
758
 
756
759
  time = event_time("2011-01-02 13:14:15 UTC")
757
760
  events = [
@@ -771,7 +774,7 @@ class HttpInputTest < Test::Unit::TestCase
771
774
  end
772
775
 
773
776
  def test_get_request
774
- d = create_driver(CONFIG)
777
+ d = create_driver(config)
775
778
 
776
779
  d.run do
777
780
  res = get("/cors.test", {}, {})
@@ -780,7 +783,7 @@ class HttpInputTest < Test::Unit::TestCase
780
783
  end
781
784
 
782
785
  def test_cors_preflight
783
- d = create_driver(CONFIG + 'cors_allow_origins ["*"]')
786
+ d = create_driver(config + 'cors_allow_origins ["*"]')
784
787
 
785
788
  d.run do
786
789
  header = {
@@ -797,7 +800,7 @@ class HttpInputTest < Test::Unit::TestCase
797
800
  end
798
801
 
799
802
  def test_cors_allowed_wildcard_for_subdomain
800
- d = create_driver(CONFIG + 'cors_allow_origins ["http://*.foo.com"]')
803
+ d = create_driver(config + 'cors_allow_origins ["http://*.foo.com"]')
801
804
 
802
805
  time = event_time("2011-01-02 13:14:15 UTC")
803
806
  events = [
@@ -817,7 +820,7 @@ class HttpInputTest < Test::Unit::TestCase
817
820
  end
818
821
 
819
822
  def test_cors_allowed_exclude_empty_string
820
- d = create_driver(CONFIG + 'cors_allow_origins ["", "http://*.foo.com"]')
823
+ d = create_driver(config + 'cors_allow_origins ["", "http://*.foo.com"]')
821
824
 
822
825
  time = event_time("2011-01-02 13:14:15 UTC")
823
826
  events = [
@@ -837,7 +840,7 @@ class HttpInputTest < Test::Unit::TestCase
837
840
  end
838
841
 
839
842
  def test_cors_allowed_wildcard_preflight_for_subdomain
840
- d = create_driver(CONFIG + 'cors_allow_origins ["http://*.foo.com"]')
843
+ d = create_driver(config + 'cors_allow_origins ["http://*.foo.com"]')
841
844
 
842
845
  d.run do
843
846
  header = {
@@ -900,7 +903,7 @@ class HttpInputTest < Test::Unit::TestCase
900
903
  end
901
904
 
902
905
  def test_cors_disallowed
903
- d = create_driver(CONFIG + "cors_allow_origins [\"http://foo.com\"]")
906
+ d = create_driver(config + "cors_allow_origins [\"http://foo.com\"]")
904
907
  assert_equal ["http://foo.com"], d.instance.cors_allow_origins
905
908
 
906
909
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -918,7 +921,7 @@ class HttpInputTest < Test::Unit::TestCase
918
921
  end
919
922
 
920
923
  def test_add_query_params
921
- d = create_driver(CONFIG + "add_query_params true")
924
+ d = create_driver(config + "add_query_params true")
922
925
  assert_equal true, d.instance.add_query_params
923
926
 
924
927
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -978,7 +981,7 @@ class HttpInputTest < Test::Unit::TestCase
978
981
  $test_in_http_content_types_flag = true
979
982
  d.run do
980
983
  # Send two requests the second one has no Content-Type in Keep-Alive
981
- Net::HTTP.start("127.0.0.1", PORT) do |http|
984
+ Net::HTTP.start("127.0.0.1", @port) do |http|
982
985
  req = Net::HTTP::Post.new("/foodb/bartbl", {"connection" => "keepalive", "Content-Type" => "application/json"})
983
986
  http.request(req)
984
987
  req = Net::HTTP::Get.new("/foodb/bartbl", {"connection" => "keepalive"})
@@ -995,19 +998,19 @@ class HttpInputTest < Test::Unit::TestCase
995
998
  end
996
999
 
997
1000
  def get(path, params, header = {})
998
- http = Net::HTTP.new("127.0.0.1", PORT)
1001
+ http = Net::HTTP.new("127.0.0.1", @port)
999
1002
  req = Net::HTTP::Get.new(path, header)
1000
1003
  http.request(req)
1001
1004
  end
1002
1005
 
1003
1006
  def options(path, params, header = {})
1004
- http = Net::HTTP.new("127.0.0.1", PORT)
1007
+ http = Net::HTTP.new("127.0.0.1", @port)
1005
1008
  req = Net::HTTP::Options.new(path, header)
1006
1009
  http.request(req)
1007
1010
  end
1008
1011
 
1009
1012
  def post(path, params, header = {}, &block)
1010
- http = Net::HTTP.new("127.0.0.1", PORT)
1013
+ http = Net::HTTP.new("127.0.0.1", @port)
1011
1014
  req = Net::HTTP::Post.new(path, header)
1012
1015
  block.call(http, req) if block
1013
1016
  if params.is_a?(String)
@@ -5,42 +5,51 @@ require 'fluent/plugin/in_syslog'
5
5
  class SyslogInputTest < 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
- CONFIG = %[
12
- port #{PORT}
13
- bind 127.0.0.1
14
- tag syslog
15
- ]
11
+ def teardown
12
+ @port = nil
13
+ end
14
+
15
+ def ipv4_config
16
+ %[
17
+ port #{@port}
18
+ bind 127.0.0.1
19
+ tag syslog
20
+ ]
21
+ end
16
22
 
17
- IPv6_CONFIG = %[
18
- port #{PORT}
19
- bind ::1
20
- tag syslog
21
- ]
23
+ def ipv6_config
24
+ %[
25
+ port #{@port}
26
+ bind ::1
27
+ tag syslog
28
+ ]
29
+ end
22
30
 
23
- def create_driver(conf=CONFIG)
31
+ def create_driver(conf=ipv4_config)
24
32
  Fluent::Test::Driver::Input.new(Fluent::Plugin::SyslogInput).configure(conf)
25
33
  end
26
34
 
27
35
  data(
28
- ipv4: ['127.0.0.1', CONFIG, ::Socket::AF_INET],
29
- ipv6: ['::1', IPv6_CONFIG, ::Socket::AF_INET6],
36
+ ipv4: ['127.0.0.1', :ipv4, ::Socket::AF_INET],
37
+ ipv6: ['::1', :ipv6, ::Socket::AF_INET6],
30
38
  )
31
39
  def test_configure(data)
32
- bind_addr, config, family = data
40
+ bind_addr, protocol, family = data
41
+ config = send("#{protocol}_config")
33
42
  omit "IPv6 unavailable" if family == ::Socket::AF_INET6 && !ipv6_enabled?
34
43
 
35
44
  d = create_driver(config)
36
- assert_equal PORT, d.instance.port
45
+ assert_equal @port, d.instance.port
37
46
  assert_equal bind_addr, d.instance.bind
38
47
  end
39
48
 
40
49
  sub_test_case 'source_hostname_key and source_address_key features' do
41
50
  test 'resolve_hostname must be true with source_hostname_key' do
42
51
  assert_raise(Fluent::ConfigError) {
43
- create_driver(CONFIG + <<EOS)
52
+ create_driver(ipv4_config + <<EOS)
44
53
  resolve_hostname false
45
54
  source_hostname_key hostname
46
55
  EOS
@@ -50,7 +59,7 @@ EOS
50
59
  data('resolve_hostname' => 'resolve_hostname true',
51
60
  'source_hostname_key' => 'source_hostname_key source_host')
52
61
  def test_configure_resolve_hostname(param)
53
- d = create_driver([CONFIG, param].join("\n"))
62
+ d = create_driver([ipv4_config, param].join("\n"))
54
63
  assert_true d.instance.resolve_hostname
55
64
  end
56
65
  end
@@ -60,7 +69,7 @@ EOS
60
69
  'Use transport and protocol' => ["protocol_type udp\n<transport tcp>\n </transport>", :udp, :tcp])
61
70
  def test_configure_protocol(param)
62
71
  conf, proto_type, transport_proto_type = *param
63
- d = create_driver([CONFIG, conf].join("\n"))
72
+ d = create_driver([ipv4_config, conf].join("\n"))
64
73
 
65
74
  assert_equal(d.instance.protocol_type, proto_type)
66
75
  assert_equal(d.instance.transport_config.protocol, transport_proto_type)
@@ -68,12 +77,12 @@ EOS
68
77
 
69
78
  # For backward compat
70
79
  def test_respect_protocol_type_than_transport
71
- d = create_driver([CONFIG, "<transport tcp> \n</transport>", "protocol_type udp"].join("\n"))
80
+ d = create_driver([ipv4_config, "<transport tcp> \n</transport>", "protocol_type udp"].join("\n"))
72
81
  tests = create_test_case
73
82
 
74
83
  d.run(expect_emits: 2) do
75
84
  u = UDPSocket.new
76
- u.connect('127.0.0.1', PORT)
85
+ u.connect('127.0.0.1', @port)
77
86
  tests.each {|test|
78
87
  u.send(test['msg'], 0)
79
88
  }
@@ -85,11 +94,12 @@ EOS
85
94
 
86
95
 
87
96
  data(
88
- ipv4: ['127.0.0.1', CONFIG, ::Socket::AF_INET],
89
- ipv6: ['::1', IPv6_CONFIG, ::Socket::AF_INET6],
97
+ ipv4: ['127.0.0.1', :ipv4, ::Socket::AF_INET],
98
+ ipv6: ['::1', :ipv6, ::Socket::AF_INET6],
90
99
  )
91
100
  def test_time_format(data)
92
- bind_addr, config, family = data
101
+ bind_addr, protocol, family = data
102
+ config = send("#{protocol}_config")
93
103
  omit "IPv6 unavailable" if family == ::Socket::AF_INET6 && !ipv6_enabled?
94
104
 
95
105
  d = create_driver(config)
@@ -100,7 +110,7 @@ EOS
100
110
  ]
101
111
  d.run(expect_emits: 2) do
102
112
  u = UDPSocket.new(family)
103
- u.connect(bind_addr, PORT)
113
+ u.connect(bind_addr, @port)
104
114
  tests.each {|test|
105
115
  u.send(test['msg'], 0)
106
116
  }
@@ -119,7 +129,7 @@ EOS
119
129
 
120
130
  d.run(expect_emits: 2) do
121
131
  u = UDPSocket.new
122
- u.connect('127.0.0.1', PORT)
132
+ u.connect('127.0.0.1', @port)
123
133
  tests.each {|test|
124
134
  u.send(test['msg'], 0)
125
135
  }
@@ -130,14 +140,14 @@ EOS
130
140
  end
131
141
 
132
142
  def test_msg_size_udp_for_large_msg
133
- d = create_driver(CONFIG + %[
143
+ d = create_driver(ipv4_config + %[
134
144
  message_length_limit 5k
135
145
  ])
136
146
  tests = create_test_case(large_message: true)
137
147
 
138
148
  d.run(expect_emits: 3) do
139
149
  u = UDPSocket.new
140
- u.connect('127.0.0.1', PORT)
150
+ u.connect('127.0.0.1', @port)
141
151
  tests.each {|test|
142
152
  u.send(test['msg'], 0)
143
153
  }
@@ -148,12 +158,12 @@ EOS
148
158
  end
149
159
 
150
160
  def test_msg_size_with_tcp
151
- d = create_driver([CONFIG, "<transport tcp> \n</transport>"].join("\n"))
161
+ d = create_driver([ipv4_config, "<transport tcp> \n</transport>"].join("\n"))
152
162
  tests = create_test_case
153
163
 
154
164
  d.run(expect_emits: 2) do
155
165
  tests.each {|test|
156
- TCPSocket.open('127.0.0.1', PORT) do |s|
166
+ TCPSocket.open('127.0.0.1', @port) do |s|
157
167
  s.send(test['msg'], 0)
158
168
  end
159
169
  }
@@ -164,12 +174,12 @@ EOS
164
174
  end
165
175
 
166
176
  def test_emit_rfc5452
167
- d = create_driver([CONFIG, "facility_key pri\n<parse>\n message_format rfc5424\nwith_priority true\n</parse>"].join("\n"))
177
+ d = create_driver([ipv4_config, "facility_key pri\n<parse>\n message_format rfc5424\nwith_priority true\n</parse>"].join("\n"))
168
178
  msg = '<1>1 2017-02-06T13:14:15.003Z myhostname 02abaf0687f5 10339 02abaf0687f5 - method=POST db=0.00'
169
179
 
170
180
  d.run(expect_emits: 1, timeout: 2) do
171
181
  u = UDPSocket.new
172
- u.connect('127.0.0.1', PORT)
182
+ u.connect('127.0.0.1', @port)
173
183
  u.send(msg, 0)
174
184
  end
175
185
 
@@ -179,11 +189,11 @@ EOS
179
189
  end
180
190
 
181
191
  def test_msg_size_with_same_tcp_connection
182
- d = create_driver([CONFIG, "<transport tcp> \n</transport>"].join("\n"))
192
+ d = create_driver([ipv4_config, "<transport tcp> \n</transport>"].join("\n"))
183
193
  tests = create_test_case
184
194
 
185
195
  d.run(expect_emits: 2) do
186
- TCPSocket.open('127.0.0.1', PORT) do |s|
196
+ TCPSocket.open('127.0.0.1', @port) do |s|
187
197
  tests.each {|test|
188
198
  s.send(test['msg'], 0)
189
199
  }
@@ -195,7 +205,7 @@ EOS
195
205
  end
196
206
 
197
207
  def test_msg_size_with_json_format
198
- d = create_driver([CONFIG, 'format json'].join("\n"))
208
+ d = create_driver([ipv4_config, 'format json'].join("\n"))
199
209
  time = Time.parse('2013-09-18 12:00:00 +0900').to_i
200
210
  tests = ['Hello!', 'Syslog!'].map { |msg|
201
211
  event = {'time' => time, 'message' => msg}
@@ -204,7 +214,7 @@ EOS
204
214
 
205
215
  d.run(expect_emits: 2) do
206
216
  u = UDPSocket.new
207
- u.connect('127.0.0.1', PORT)
217
+ u.connect('127.0.0.1', @port)
208
218
  tests.each {|test|
209
219
  u.send(test['msg'], 0)
210
220
  }
@@ -215,13 +225,13 @@ EOS
215
225
  end
216
226
 
217
227
  def test_msg_size_with_include_source_host
218
- d = create_driver([CONFIG, 'include_source_host true'].join("\n"))
228
+ d = create_driver([ipv4_config, 'include_source_host true'].join("\n"))
219
229
  tests = create_test_case
220
230
 
221
231
  host = nil
222
232
  d.run(expect_emits: 2) do
223
233
  u = UDPSocket.new
224
- u.connect('127.0.0.1', PORT)
234
+ u.connect('127.0.0.1', @port)
225
235
  host = u.peeraddr[2]
226
236
  tests.each {|test|
227
237
  u.send(test['msg'], 0)
@@ -237,13 +247,13 @@ EOS
237
247
  priority_key: 'priority_key',
238
248
  )
239
249
  def test_msg_size_with_severity_key(param_name)
240
- d = create_driver([CONFIG, "#{param_name} severity"].join("\n"))
250
+ d = create_driver([ipv4_config, "#{param_name} severity"].join("\n"))
241
251
  tests = create_test_case
242
252
 
243
253
  severity = 'info'
244
254
  d.run(expect_emits: 2) do
245
255
  u = UDPSocket.new
246
- u.connect('127.0.0.1', PORT)
256
+ u.connect('127.0.0.1', @port)
247
257
  tests.each {|test|
248
258
  u.send(test['msg'], 0)
249
259
  }
@@ -254,13 +264,13 @@ EOS
254
264
  end
255
265
 
256
266
  def test_msg_size_with_facility_key
257
- d = create_driver([CONFIG, 'facility_key facility'].join("\n"))
267
+ d = create_driver([ipv4_config, 'facility_key facility'].join("\n"))
258
268
  tests = create_test_case
259
269
 
260
270
  facility = 'kern'
261
271
  d.run(expect_emits: 2) do
262
272
  u = UDPSocket.new
263
- u.connect('127.0.0.1', PORT)
273
+ u.connect('127.0.0.1', @port)
264
274
  tests.each {|test|
265
275
  u.send(test['msg'], 0)
266
276
  }
@@ -271,13 +281,13 @@ EOS
271
281
  end
272
282
 
273
283
  def test_msg_size_with_source_address_key
274
- d = create_driver([CONFIG, 'source_address_key source_address'].join("\n"))
284
+ d = create_driver([ipv4_config, 'source_address_key source_address'].join("\n"))
275
285
  tests = create_test_case
276
286
 
277
287
  address = nil
278
288
  d.run(expect_emits: 2) do
279
289
  u = UDPSocket.new
280
- u.connect('127.0.0.1', PORT)
290
+ u.connect('127.0.0.1', @port)
281
291
  address = u.peeraddr[3]
282
292
  tests.each {|test|
283
293
  u.send(test['msg'], 0)
@@ -289,14 +299,14 @@ EOS
289
299
  end
290
300
 
291
301
  def test_msg_size_with_source_hostname_key
292
- d = create_driver([CONFIG, 'source_hostname_key source_hostname'].join("\n"))
302
+ d = create_driver([ipv4_config, 'source_hostname_key source_hostname'].join("\n"))
293
303
  tests = create_test_case
294
304
 
295
305
  hostname = nil
296
306
  d.run(expect_emits: 2) do
297
307
  u = UDPSocket.new
298
308
  u.do_not_reverse_lookup = false
299
- u.connect('127.0.0.1', PORT)
309
+ u.connect('127.0.0.1', @port)
300
310
  hostname = u.peeraddr[2]
301
311
  tests.each {|test|
302
312
  u.send(test['msg'], 0)
@@ -337,12 +347,12 @@ EOS
337
347
 
338
348
  sub_test_case 'octet counting frame' do
339
349
  def test_msg_size_with_tcp
340
- d = create_driver([CONFIG, "<transport tcp> \n</transport>", 'frame_type octet_count'].join("\n"))
350
+ d = create_driver([ipv4_config, "<transport tcp> \n</transport>", 'frame_type octet_count'].join("\n"))
341
351
  tests = create_test_case
342
352
 
343
353
  d.run(expect_emits: 2) do
344
354
  tests.each {|test|
345
- TCPSocket.open('127.0.0.1', PORT) do |s|
355
+ TCPSocket.open('127.0.0.1', @port) do |s|
346
356
  s.send(test['msg'], 0)
347
357
  end
348
358
  }
@@ -353,11 +363,11 @@ EOS
353
363
  end
354
364
 
355
365
  def test_msg_size_with_same_tcp_connection
356
- d = create_driver([CONFIG, "<transport tcp> \n</transport>", 'frame_type octet_count'].join("\n"))
366
+ d = create_driver([ipv4_config, "<transport tcp> \n</transport>", 'frame_type octet_count'].join("\n"))
357
367
  tests = create_test_case
358
368
 
359
369
  d.run(expect_emits: 2) do
360
- TCPSocket.open('127.0.0.1', PORT) do |s|
370
+ TCPSocket.open('127.0.0.1', @port) do |s|
361
371
  tests.each {|test|
362
372
  s.send(test['msg'], 0)
363
373
  }
@@ -404,13 +414,13 @@ EOS
404
414
  end
405
415
 
406
416
  def test_emit_unmatched_lines
407
- d = create_driver([CONFIG, 'emit_unmatched_lines true'].join("\n"))
417
+ d = create_driver([ipv4_config, 'emit_unmatched_lines true'].join("\n"))
408
418
  tests = create_unmatched_lines_test_case
409
419
 
410
420
  d.run(expect_emits: 3) do
411
421
  u = UDPSocket.new
412
422
  u.do_not_reverse_lookup = false
413
- u.connect('127.0.0.1', PORT)
423
+ u.connect('127.0.0.1', @port)
414
424
  tests.each {|test|
415
425
  u.send(test['msg'], 0)
416
426
  }
@@ -421,14 +431,14 @@ EOS
421
431
  end
422
432
 
423
433
  def test_emit_unmatched_lines_with_hostname
424
- d = create_driver([CONFIG, 'emit_unmatched_lines true', 'source_hostname_key source_hostname'].join("\n"))
434
+ d = create_driver([ipv4_config, 'emit_unmatched_lines true', 'source_hostname_key source_hostname'].join("\n"))
425
435
  tests = create_unmatched_lines_test_case
426
436
 
427
437
  hostname = nil
428
438
  d.run(expect_emits: 3) do
429
439
  u = UDPSocket.new
430
440
  u.do_not_reverse_lookup = false
431
- u.connect('127.0.0.1', PORT)
441
+ u.connect('127.0.0.1', @port)
432
442
  hostname = u.peeraddr[2]
433
443
  tests.each {|test|
434
444
  u.send(test['msg'], 0)
@@ -440,14 +450,14 @@ EOS
440
450
  end
441
451
 
442
452
  def test_emit_unmatched_lines_with_address
443
- d = create_driver([CONFIG, 'emit_unmatched_lines true', 'source_address_key source_address'].join("\n"))
453
+ d = create_driver([ipv4_config, 'emit_unmatched_lines true', 'source_address_key source_address'].join("\n"))
444
454
  tests = create_unmatched_lines_test_case
445
455
 
446
456
  address = nil
447
457
  d.run(expect_emits: 3) do
448
458
  u = UDPSocket.new
449
459
  u.do_not_reverse_lookup = false
450
- u.connect('127.0.0.1', PORT)
460
+ u.connect('127.0.0.1', @port)
451
461
  address = u.peeraddr[3]
452
462
  tests.each {|test|
453
463
  u.send(test['msg'], 0)