fluent-plugin-http-pull 0.7.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -1
- data/.gitignore +8 -8
- data/.travis.yml +10 -10
- data/Gemfile +3 -3
- data/LICENSE +202 -202
- data/README.md +227 -204
- data/Rakefile +24 -24
- data/appveyor.yml +23 -23
- data/fluent-plugin-http-pull.gemspec +33 -33
- data/lib/fluent/plugin/in_http_pull.rb +168 -147
- data/test/helper.rb +29 -29
- data/test/helper/.ssl/README +25 -0
- data/test/helper/.ssl/server.crt +19 -0
- data/test/helper/.ssl/server.csr +16 -0
- data/test/helper/.ssl/server.key +27 -0
- data/test/helper/.ssl/server.key.org +30 -0
- data/test/helper/stub_proxy.rb +39 -39
- data/test/helper/stub_server.rb +134 -119
- data/test/plugin/test_in_http_pull.rb +92 -71
- data/test/plugin/test_in_http_pull_auth.rb +116 -116
- data/test/plugin/test_in_http_pull_basic.rb +228 -227
- data/test/plugin/test_in_http_pull_http_header.rb +126 -126
- data/test/plugin/test_in_http_pull_proxy.rb +119 -119
- data/test/plugin/test_in_http_pull_request_method.rb +79 -79
- data/test/plugin/test_in_http_pull_ssl.rb +173 -0
- metadata +14 -2
@@ -1,126 +1,126 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "fluent/plugin/in_http_pull.rb"
|
3
|
-
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
class HttpPullInputTestHttpHeader < Test::Unit::TestCase
|
7
|
-
@stub_server = nil
|
8
|
-
|
9
|
-
setup do
|
10
|
-
@stub_server = StubServer.new
|
11
|
-
@stub_server.start
|
12
|
-
end
|
13
|
-
|
14
|
-
teardown do
|
15
|
-
@stub_server.shutdown
|
16
|
-
end
|
17
|
-
|
18
|
-
sub_test_case "capture response header" do
|
19
|
-
TEST_INTERVAL_3_RES_HEADER_CONFIG = %[
|
20
|
-
tag test
|
21
|
-
url http://
|
22
|
-
|
23
|
-
interval 3s
|
24
|
-
format json
|
25
|
-
|
26
|
-
<response_header>
|
27
|
-
header Content-Type
|
28
|
-
</response_header>
|
29
|
-
]
|
30
|
-
|
31
|
-
TEST_INTERVAL_3_RES_MULTI_HEADER_CONFIG = %[
|
32
|
-
tag test
|
33
|
-
url http://
|
34
|
-
|
35
|
-
interval 3s
|
36
|
-
format json
|
37
|
-
|
38
|
-
<response_header>
|
39
|
-
header Content-Type
|
40
|
-
</response_header>
|
41
|
-
|
42
|
-
<response_header>
|
43
|
-
header Content-Length
|
44
|
-
</response_header>
|
45
|
-
]
|
46
|
-
|
47
|
-
test 'interval 3 with single header' do
|
48
|
-
d = create_driver TEST_INTERVAL_3_RES_HEADER_CONFIG
|
49
|
-
assert_equal("test", d.instance.tag)
|
50
|
-
assert_equal(3, d.instance.interval)
|
51
|
-
|
52
|
-
d.run(timeout: 8) do
|
53
|
-
sleep 7
|
54
|
-
end
|
55
|
-
assert_equal(2, d.events.size)
|
56
|
-
|
57
|
-
d.events.each do |tag, time, record|
|
58
|
-
assert_equal("test", tag)
|
59
|
-
|
60
|
-
assert_equal({"url"=>"http://
|
61
|
-
assert(time.is_a?(Fluent::EventTime))
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
test 'interval 3 with multiple header' do
|
66
|
-
d = create_driver TEST_INTERVAL_3_RES_MULTI_HEADER_CONFIG
|
67
|
-
assert_equal("test", d.instance.tag)
|
68
|
-
assert_equal(3, d.instance.interval)
|
69
|
-
|
70
|
-
d.run(timeout: 8) do
|
71
|
-
sleep 7
|
72
|
-
end
|
73
|
-
assert_equal(2, d.events.size)
|
74
|
-
|
75
|
-
d.events.each do |tag, time, record|
|
76
|
-
assert_equal("test", tag)
|
77
|
-
|
78
|
-
assert_equal({"url"=>"http://
|
79
|
-
assert(time.is_a?(Fluent::EventTime))
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
sub_test_case "custom request header" do
|
85
|
-
TEST_INTERVAL_3_CUSTOM_HEADER_CONFIG = %[
|
86
|
-
tag test
|
87
|
-
url http://
|
88
|
-
|
89
|
-
interval 3s
|
90
|
-
format json
|
91
|
-
|
92
|
-
<request_header>
|
93
|
-
header HATSUNE-MIKU
|
94
|
-
value 3939
|
95
|
-
</request_header>
|
96
|
-
|
97
|
-
<response_header>
|
98
|
-
header HATSUNE-MIKU
|
99
|
-
</response_header>
|
100
|
-
]
|
101
|
-
|
102
|
-
test 'interval 3 with single header' do
|
103
|
-
d = create_driver TEST_INTERVAL_3_CUSTOM_HEADER_CONFIG
|
104
|
-
assert_equal("test", d.instance.tag)
|
105
|
-
assert_equal(3, d.instance.interval)
|
106
|
-
|
107
|
-
d.run(timeout: 8) do
|
108
|
-
sleep 7
|
109
|
-
end
|
110
|
-
assert_equal(2, d.events.size)
|
111
|
-
|
112
|
-
d.events.each do |tag, time, record|
|
113
|
-
assert_equal("test", tag)
|
114
|
-
|
115
|
-
assert_equal({"url"=>"http://
|
116
|
-
assert(time.is_a?(Fluent::EventTime))
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
|
123
|
-
def create_driver(conf)
|
124
|
-
Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpPullInput).configure(conf)
|
125
|
-
end
|
126
|
-
end
|
1
|
+
require "helper"
|
2
|
+
require "fluent/plugin/in_http_pull.rb"
|
3
|
+
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
class HttpPullInputTestHttpHeader < Test::Unit::TestCase
|
7
|
+
@stub_server = nil
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@stub_server = StubServer.new
|
11
|
+
@stub_server.start
|
12
|
+
end
|
13
|
+
|
14
|
+
teardown do
|
15
|
+
@stub_server.shutdown
|
16
|
+
end
|
17
|
+
|
18
|
+
sub_test_case "capture response header" do
|
19
|
+
TEST_INTERVAL_3_RES_HEADER_CONFIG = %[
|
20
|
+
tag test
|
21
|
+
url http://localhost:3939
|
22
|
+
|
23
|
+
interval 3s
|
24
|
+
format json
|
25
|
+
|
26
|
+
<response_header>
|
27
|
+
header Content-Type
|
28
|
+
</response_header>
|
29
|
+
]
|
30
|
+
|
31
|
+
TEST_INTERVAL_3_RES_MULTI_HEADER_CONFIG = %[
|
32
|
+
tag test
|
33
|
+
url http://localhost:3939
|
34
|
+
|
35
|
+
interval 3s
|
36
|
+
format json
|
37
|
+
|
38
|
+
<response_header>
|
39
|
+
header Content-Type
|
40
|
+
</response_header>
|
41
|
+
|
42
|
+
<response_header>
|
43
|
+
header Content-Length
|
44
|
+
</response_header>
|
45
|
+
]
|
46
|
+
|
47
|
+
test 'interval 3 with single header' do
|
48
|
+
d = create_driver TEST_INTERVAL_3_RES_HEADER_CONFIG
|
49
|
+
assert_equal("test", d.instance.tag)
|
50
|
+
assert_equal(3, d.instance.interval)
|
51
|
+
|
52
|
+
d.run(timeout: 8) do
|
53
|
+
sleep 7
|
54
|
+
end
|
55
|
+
assert_equal(2, d.events.size)
|
56
|
+
|
57
|
+
d.events.each do |tag, time, record|
|
58
|
+
assert_equal("test", tag)
|
59
|
+
|
60
|
+
assert_equal({"url"=>"http://localhost:3939","status"=>200,"message"=>{"status"=>"OK"},"header"=>{"Content-Type"=>"application/json"}}, record)
|
61
|
+
assert(time.is_a?(Fluent::EventTime))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
test 'interval 3 with multiple header' do
|
66
|
+
d = create_driver TEST_INTERVAL_3_RES_MULTI_HEADER_CONFIG
|
67
|
+
assert_equal("test", d.instance.tag)
|
68
|
+
assert_equal(3, d.instance.interval)
|
69
|
+
|
70
|
+
d.run(timeout: 8) do
|
71
|
+
sleep 7
|
72
|
+
end
|
73
|
+
assert_equal(2, d.events.size)
|
74
|
+
|
75
|
+
d.events.each do |tag, time, record|
|
76
|
+
assert_equal("test", tag)
|
77
|
+
|
78
|
+
assert_equal({"url"=>"http://localhost:3939","status"=>200,"message"=>{"status"=>"OK"},"header"=>{"Content-Type"=>"application/json","Content-Length"=>"18"}}, record)
|
79
|
+
assert(time.is_a?(Fluent::EventTime))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
sub_test_case "custom request header" do
|
85
|
+
TEST_INTERVAL_3_CUSTOM_HEADER_CONFIG = %[
|
86
|
+
tag test
|
87
|
+
url http://localhost:3939/custom_header
|
88
|
+
|
89
|
+
interval 3s
|
90
|
+
format json
|
91
|
+
|
92
|
+
<request_header>
|
93
|
+
header HATSUNE-MIKU
|
94
|
+
value 3939
|
95
|
+
</request_header>
|
96
|
+
|
97
|
+
<response_header>
|
98
|
+
header HATSUNE-MIKU
|
99
|
+
</response_header>
|
100
|
+
]
|
101
|
+
|
102
|
+
test 'interval 3 with single header' do
|
103
|
+
d = create_driver TEST_INTERVAL_3_CUSTOM_HEADER_CONFIG
|
104
|
+
assert_equal("test", d.instance.tag)
|
105
|
+
assert_equal(3, d.instance.interval)
|
106
|
+
|
107
|
+
d.run(timeout: 8) do
|
108
|
+
sleep 7
|
109
|
+
end
|
110
|
+
assert_equal(2, d.events.size)
|
111
|
+
|
112
|
+
d.events.each do |tag, time, record|
|
113
|
+
assert_equal("test", tag)
|
114
|
+
|
115
|
+
assert_equal({"url"=>"http://localhost:3939/custom_header","status"=>200,"message"=>{"status"=>"OK"},"header"=>{"HATSUNE-MIKU"=>"3939"}}, record)
|
116
|
+
assert(time.is_a?(Fluent::EventTime))
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def create_driver(conf)
|
124
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpPullInput).configure(conf)
|
125
|
+
end
|
126
|
+
end
|
@@ -1,119 +1,119 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "fluent/plugin/in_http_pull.rb"
|
3
|
-
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
class HttpPullInputTestProxy < Test::Unit::TestCase
|
7
|
-
@stub_server = nil
|
8
|
-
|
9
|
-
setup do
|
10
|
-
@stub_server = StubServer.new
|
11
|
-
@stub_server.start
|
12
|
-
end
|
13
|
-
|
14
|
-
teardown do
|
15
|
-
@stub_server.shutdown
|
16
|
-
end
|
17
|
-
|
18
|
-
sub_test_case "success case behind proxy" do
|
19
|
-
TEST_INTERVAL_3_PROXY_CONFIG = %[
|
20
|
-
tag test
|
21
|
-
url http://
|
22
|
-
proxy http://
|
23
|
-
|
24
|
-
interval 3s
|
25
|
-
format none
|
26
|
-
status_only true
|
27
|
-
]
|
28
|
-
|
29
|
-
TEST_INTERVAL_3_REDIRECT_PROXY_CONFIG = %[
|
30
|
-
tag test
|
31
|
-
url http://
|
32
|
-
proxy http://
|
33
|
-
|
34
|
-
interval 3s
|
35
|
-
format json
|
36
|
-
]
|
37
|
-
|
38
|
-
TEST_AUTH_SUCCESS_PROXY_CONFIG = %[
|
39
|
-
tag test
|
40
|
-
url http://
|
41
|
-
proxy http://
|
42
|
-
timeout 2s
|
43
|
-
user HatsuneMiku
|
44
|
-
password 3939
|
45
|
-
|
46
|
-
interval 3s
|
47
|
-
format json
|
48
|
-
]
|
49
|
-
|
50
|
-
setup do
|
51
|
-
@proxy_server = StubProxy.new
|
52
|
-
@proxy_server.start
|
53
|
-
end
|
54
|
-
|
55
|
-
teardown do
|
56
|
-
@proxy_server.shutdown
|
57
|
-
end
|
58
|
-
|
59
|
-
test 'interval 3 with status_only' do
|
60
|
-
d = create_driver TEST_INTERVAL_3_PROXY_CONFIG
|
61
|
-
assert_equal("test", d.instance.tag)
|
62
|
-
assert_equal(3, d.instance.interval)
|
63
|
-
|
64
|
-
d.run(timeout: 8) do
|
65
|
-
sleep 7
|
66
|
-
end
|
67
|
-
assert_equal(2, d.events.size)
|
68
|
-
|
69
|
-
d.events.each do |tag, time, record|
|
70
|
-
assert_equal("test", tag)
|
71
|
-
|
72
|
-
assert_equal({"url"=>"http://
|
73
|
-
assert(time.is_a?(Fluent::EventTime))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
test 'interval 3 with redirect' do
|
78
|
-
d = create_driver TEST_INTERVAL_3_REDIRECT_PROXY_CONFIG
|
79
|
-
assert_equal("test", d.instance.tag)
|
80
|
-
assert_equal(3, d.instance.interval)
|
81
|
-
|
82
|
-
d.run(timeout: 8) do
|
83
|
-
sleep 7
|
84
|
-
end
|
85
|
-
assert_equal(2, d.events.size)
|
86
|
-
|
87
|
-
d.events.each do |tag, time, record|
|
88
|
-
assert_equal("test", tag)
|
89
|
-
|
90
|
-
assert_equal({"url"=>"http://
|
91
|
-
assert(time.is_a?(Fluent::EventTime))
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
test 'interval 3 with corrent password' do
|
96
|
-
d = create_driver TEST_AUTH_SUCCESS_PROXY_CONFIG
|
97
|
-
assert_equal("test", d.instance.tag)
|
98
|
-
assert_equal(3, d.instance.interval)
|
99
|
-
|
100
|
-
d.run(timeout: 8) do
|
101
|
-
sleep 7
|
102
|
-
end
|
103
|
-
assert_equal(2, d.events.size)
|
104
|
-
|
105
|
-
d.events.each do |tag, time, record|
|
106
|
-
assert_equal("test", tag)
|
107
|
-
|
108
|
-
assert_equal({"url"=>"http://
|
109
|
-
assert(time.is_a?(Fluent::EventTime))
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
private
|
115
|
-
|
116
|
-
def create_driver(conf)
|
117
|
-
Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpPullInput).configure(conf)
|
118
|
-
end
|
119
|
-
end
|
1
|
+
require "helper"
|
2
|
+
require "fluent/plugin/in_http_pull.rb"
|
3
|
+
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
class HttpPullInputTestProxy < Test::Unit::TestCase
|
7
|
+
@stub_server = nil
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@stub_server = StubServer.new
|
11
|
+
@stub_server.start
|
12
|
+
end
|
13
|
+
|
14
|
+
teardown do
|
15
|
+
@stub_server.shutdown
|
16
|
+
end
|
17
|
+
|
18
|
+
sub_test_case "success case behind proxy" do
|
19
|
+
TEST_INTERVAL_3_PROXY_CONFIG = %[
|
20
|
+
tag test
|
21
|
+
url http://localhost:3939
|
22
|
+
proxy http://localhost:4040
|
23
|
+
|
24
|
+
interval 3s
|
25
|
+
format none
|
26
|
+
status_only true
|
27
|
+
]
|
28
|
+
|
29
|
+
TEST_INTERVAL_3_REDIRECT_PROXY_CONFIG = %[
|
30
|
+
tag test
|
31
|
+
url http://localhost:3939/redirect
|
32
|
+
proxy http://localhost:4040
|
33
|
+
|
34
|
+
interval 3s
|
35
|
+
format json
|
36
|
+
]
|
37
|
+
|
38
|
+
TEST_AUTH_SUCCESS_PROXY_CONFIG = %[
|
39
|
+
tag test
|
40
|
+
url http://localhost:3939/protected
|
41
|
+
proxy http://localhost:4040
|
42
|
+
timeout 2s
|
43
|
+
user HatsuneMiku
|
44
|
+
password 3939
|
45
|
+
|
46
|
+
interval 3s
|
47
|
+
format json
|
48
|
+
]
|
49
|
+
|
50
|
+
setup do
|
51
|
+
@proxy_server = StubProxy.new
|
52
|
+
@proxy_server.start
|
53
|
+
end
|
54
|
+
|
55
|
+
teardown do
|
56
|
+
@proxy_server.shutdown
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'interval 3 with status_only' do
|
60
|
+
d = create_driver TEST_INTERVAL_3_PROXY_CONFIG
|
61
|
+
assert_equal("test", d.instance.tag)
|
62
|
+
assert_equal(3, d.instance.interval)
|
63
|
+
|
64
|
+
d.run(timeout: 8) do
|
65
|
+
sleep 7
|
66
|
+
end
|
67
|
+
assert_equal(2, d.events.size)
|
68
|
+
|
69
|
+
d.events.each do |tag, time, record|
|
70
|
+
assert_equal("test", tag)
|
71
|
+
|
72
|
+
assert_equal({"url"=>"http://localhost:3939","status"=>200}, record)
|
73
|
+
assert(time.is_a?(Fluent::EventTime))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
test 'interval 3 with redirect' do
|
78
|
+
d = create_driver TEST_INTERVAL_3_REDIRECT_PROXY_CONFIG
|
79
|
+
assert_equal("test", d.instance.tag)
|
80
|
+
assert_equal(3, d.instance.interval)
|
81
|
+
|
82
|
+
d.run(timeout: 8) do
|
83
|
+
sleep 7
|
84
|
+
end
|
85
|
+
assert_equal(2, d.events.size)
|
86
|
+
|
87
|
+
d.events.each do |tag, time, record|
|
88
|
+
assert_equal("test", tag)
|
89
|
+
|
90
|
+
assert_equal({"url"=>"http://localhost:3939/redirect","status"=>200, "message"=>{"status"=>"OK"}}, record)
|
91
|
+
assert(time.is_a?(Fluent::EventTime))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
test 'interval 3 with corrent password' do
|
96
|
+
d = create_driver TEST_AUTH_SUCCESS_PROXY_CONFIG
|
97
|
+
assert_equal("test", d.instance.tag)
|
98
|
+
assert_equal(3, d.instance.interval)
|
99
|
+
|
100
|
+
d.run(timeout: 8) do
|
101
|
+
sleep 7
|
102
|
+
end
|
103
|
+
assert_equal(2, d.events.size)
|
104
|
+
|
105
|
+
d.events.each do |tag, time, record|
|
106
|
+
assert_equal("test", tag)
|
107
|
+
|
108
|
+
assert_equal({"url"=>"http://localhost:3939/protected","status"=>200, "message"=>{"status"=>"OK"}}, record)
|
109
|
+
assert(time.is_a?(Fluent::EventTime))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def create_driver(conf)
|
117
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpPullInput).configure(conf)
|
118
|
+
end
|
119
|
+
end
|