fluentd 1.12.2-x86-mingw32 → 1.13.2-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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.yaml +69 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yaml +38 -0
- data/.github/workflows/linux-test.yaml +1 -1
- data/.github/workflows/windows-test.yaml +19 -3
- data/.gitlab-ci.yml +19 -19
- data/CHANGELOG.md +153 -0
- data/CONTRIBUTING.md +2 -2
- data/MAINTAINERS.md +1 -1
- data/README.md +8 -5
- data/bin/fluentd +8 -1
- data/example/counter.conf +1 -1
- data/fluentd.gemspec +4 -3
- data/lib/fluent/command/cat.rb +19 -3
- data/lib/fluent/command/fluentd.rb +1 -2
- data/lib/fluent/command/plugin_generator.rb +42 -2
- data/lib/fluent/config.rb +1 -1
- data/lib/fluent/config/section.rb +5 -0
- data/lib/fluent/config/types.rb +15 -0
- data/lib/fluent/config/v1_parser.rb +3 -2
- data/lib/fluent/env.rb +2 -1
- data/lib/fluent/log.rb +1 -0
- data/lib/fluent/oj_options.rb +62 -0
- data/lib/fluent/plugin/file_wrapper.rb +49 -4
- data/lib/fluent/plugin/formatter.rb +1 -0
- data/lib/fluent/plugin/formatter_json.rb +9 -7
- data/lib/fluent/plugin/in_http.rb +10 -0
- data/lib/fluent/plugin/in_tail.rb +150 -39
- data/lib/fluent/plugin/in_tail/position_file.rb +15 -1
- data/lib/fluent/plugin/out_forward.rb +14 -33
- data/lib/fluent/plugin/output.rb +11 -9
- data/lib/fluent/plugin/parser_csv.rb +2 -2
- data/lib/fluent/plugin/parser_json.rb +2 -3
- data/lib/fluent/plugin/parser_syslog.rb +2 -2
- data/lib/fluent/plugin/service_discovery.rb +0 -15
- data/lib/fluent/plugin/storage_local.rb +1 -1
- data/lib/fluent/plugin_helper/http_server/router.rb +1 -1
- data/lib/fluent/plugin_helper/server.rb +4 -2
- data/lib/fluent/plugin_helper/service_discovery.rb +39 -1
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +11 -5
- data/lib/fluent/plugin_helper/socket_option.rb +2 -2
- data/lib/fluent/supervisor.rb +15 -0
- data/lib/fluent/system_config.rb +14 -0
- data/lib/fluent/test/driver/storage.rb +30 -0
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/fluent-plugin.gemspec.erb +3 -3
- data/templates/new_gem/lib/fluent/plugin/storage.rb.erb +40 -0
- data/templates/new_gem/test/plugin/test_storage.rb.erb +18 -0
- data/test/command/test_cat.rb +99 -0
- data/test/command/test_plugin_generator.rb +2 -1
- data/test/config/test_section.rb +9 -0
- data/test/config/test_system_config.rb +46 -0
- data/test/config/test_types.rb +7 -0
- data/test/plugin/in_tail/test_io_handler.rb +4 -4
- data/test/plugin/in_tail/test_position_file.rb +54 -0
- data/test/plugin/out_forward/test_connection_manager.rb +0 -6
- data/test/plugin/test_file_wrapper.rb +115 -0
- data/test/plugin/test_in_forward.rb +59 -83
- data/test/plugin/test_in_http.rb +58 -40
- data/test/plugin/test_in_syslog.rb +66 -56
- data/test/plugin/test_in_tail.rb +329 -10
- data/test/plugin/test_in_tcp.rb +45 -32
- data/test/plugin/test_in_udp.rb +47 -33
- data/test/plugin/test_out_forward.rb +138 -105
- data/test/plugin/test_out_stream.rb +18 -8
- data/test/plugin/test_output.rb +15 -3
- data/test/plugin/test_output_as_buffered_backup.rb +2 -0
- data/test/plugin/test_parser_csv.rb +14 -0
- data/test/plugin/test_parser_syslog.rb +14 -0
- data/test/plugin_helper/http_server/test_route.rb +1 -1
- data/test/plugin_helper/service_discovery/test_manager.rb +1 -1
- data/test/plugin_helper/test_child_process.rb +1 -1
- data/test/plugin_helper/test_http_server_helper.rb +34 -27
- data/test/plugin_helper/test_server.rb +144 -139
- data/test/plugin_helper/test_service_discovery.rb +74 -14
- data/test/plugin_helper/test_socket.rb +16 -9
- data/test/test_config.rb +2 -1
- data/test/test_event_time.rb +2 -2
- data/test/test_oj_options.rb +55 -0
- data/test/test_output.rb +2 -2
- data/test/test_supervisor.rb +35 -0
- metadata +41 -11
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
data/test/plugin/test_in_http.rb
CHANGED
@@ -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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
37
40
|
|
38
|
-
def create_driver(conf=
|
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
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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 = [
|
@@ -770,8 +773,17 @@ class HttpInputTest < Test::Unit::TestCase
|
|
770
773
|
end
|
771
774
|
end
|
772
775
|
|
776
|
+
def test_get_request
|
777
|
+
d = create_driver(config)
|
778
|
+
|
779
|
+
d.run do
|
780
|
+
res = get("/cors.test", {}, {})
|
781
|
+
assert_equal "200", res.code
|
782
|
+
end
|
783
|
+
end
|
784
|
+
|
773
785
|
def test_cors_preflight
|
774
|
-
d = create_driver(
|
786
|
+
d = create_driver(config + 'cors_allow_origins ["*"]')
|
775
787
|
|
776
788
|
d.run do
|
777
789
|
header = {
|
@@ -788,7 +800,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
788
800
|
end
|
789
801
|
|
790
802
|
def test_cors_allowed_wildcard_for_subdomain
|
791
|
-
d = create_driver(
|
803
|
+
d = create_driver(config + 'cors_allow_origins ["http://*.foo.com"]')
|
792
804
|
|
793
805
|
time = event_time("2011-01-02 13:14:15 UTC")
|
794
806
|
events = [
|
@@ -808,7 +820,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
808
820
|
end
|
809
821
|
|
810
822
|
def test_cors_allowed_exclude_empty_string
|
811
|
-
d = create_driver(
|
823
|
+
d = create_driver(config + 'cors_allow_origins ["", "http://*.foo.com"]')
|
812
824
|
|
813
825
|
time = event_time("2011-01-02 13:14:15 UTC")
|
814
826
|
events = [
|
@@ -828,7 +840,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
828
840
|
end
|
829
841
|
|
830
842
|
def test_cors_allowed_wildcard_preflight_for_subdomain
|
831
|
-
d = create_driver(
|
843
|
+
d = create_driver(config + 'cors_allow_origins ["http://*.foo.com"]')
|
832
844
|
|
833
845
|
d.run do
|
834
846
|
header = {
|
@@ -891,7 +903,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
891
903
|
end
|
892
904
|
|
893
905
|
def test_cors_disallowed
|
894
|
-
d = create_driver(
|
906
|
+
d = create_driver(config + "cors_allow_origins [\"http://foo.com\"]")
|
895
907
|
assert_equal ["http://foo.com"], d.instance.cors_allow_origins
|
896
908
|
|
897
909
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -909,7 +921,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
909
921
|
end
|
910
922
|
|
911
923
|
def test_add_query_params
|
912
|
-
d = create_driver(
|
924
|
+
d = create_driver(config + "add_query_params true")
|
913
925
|
assert_equal true, d.instance.add_query_params
|
914
926
|
|
915
927
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -969,7 +981,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
969
981
|
$test_in_http_content_types_flag = true
|
970
982
|
d.run do
|
971
983
|
# Send two requests the second one has no Content-Type in Keep-Alive
|
972
|
-
Net::HTTP.start("127.0.0.1",
|
984
|
+
Net::HTTP.start("127.0.0.1", @port) do |http|
|
973
985
|
req = Net::HTTP::Post.new("/foodb/bartbl", {"connection" => "keepalive", "Content-Type" => "application/json"})
|
974
986
|
http.request(req)
|
975
987
|
req = Net::HTTP::Get.new("/foodb/bartbl", {"connection" => "keepalive"})
|
@@ -985,14 +997,20 @@ class HttpInputTest < Test::Unit::TestCase
|
|
985
997
|
assert_equal $test_in_http_connection_object_ids[0], $test_in_http_connection_object_ids[1]
|
986
998
|
end
|
987
999
|
|
1000
|
+
def get(path, params, header = {})
|
1001
|
+
http = Net::HTTP.new("127.0.0.1", @port)
|
1002
|
+
req = Net::HTTP::Get.new(path, header)
|
1003
|
+
http.request(req)
|
1004
|
+
end
|
1005
|
+
|
988
1006
|
def options(path, params, header = {})
|
989
|
-
http = Net::HTTP.new("127.0.0.1",
|
1007
|
+
http = Net::HTTP.new("127.0.0.1", @port)
|
990
1008
|
req = Net::HTTP::Options.new(path, header)
|
991
1009
|
http.request(req)
|
992
1010
|
end
|
993
1011
|
|
994
1012
|
def post(path, params, header = {}, &block)
|
995
|
-
http = Net::HTTP.new("127.0.0.1",
|
1013
|
+
http = Net::HTTP.new("127.0.0.1", @port)
|
996
1014
|
req = Net::HTTP::Post.new(path, header)
|
997
1015
|
block.call(http, req) if block
|
998
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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=
|
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',
|
29
|
-
ipv6: ['::1',
|
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,
|
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
|
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(
|
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([
|
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([
|
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([
|
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',
|
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',
|
89
|
-
ipv6: ['::1',
|
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,
|
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,
|
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',
|
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(
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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([
|
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',
|
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)
|