fluent-plugin-out-http-ext 0.1.5.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18cacab722418c7993224de7d95fb10c4a399cdb
4
- data.tar.gz: d0f8ac309fc40824d9778b45f9761ed6490d8e69
3
+ metadata.gz: 3e9c08d1a809ddd3df73b5ab13fe55ac7ed79305
4
+ data.tar.gz: 2af17adfcbb3375ab1079dfcc56d51d2a64d0b06
5
5
  SHA512:
6
- metadata.gz: 59a8e361b6453eed63590dfdb0f1e47d90432681858311f71417779cfdc61c7aede95cd6e58b69619dcf4da82ecb72103fad3291444e05afe7fa4ec7e965c996
7
- data.tar.gz: 4efceb4ff4fd906ccddbc36ac504339c3fdf73838a75bdbf2ba28da69b1a0714fc4d2c88d82b9b72f563fa19ee3954789a7df2a90ff2169dd7510ff0abd18da4
6
+ metadata.gz: 4c445f8eb6d35bf52705eeb683ff48f15d96b5eadc8625736ce98cd2b52d9f207a4e08ba6abd2ac8306b025d0626eae55e3204ab3806638fdd4468c19b7699d4
7
+ data.tar.gz: 66977734544084539b681b6690e82fef9cb595badfb57cd509f97f1cdf196afd3e314e0697bda3a25175f119bdb78b278237ee8ee1c7d2e3e515bb50d99f7bb6
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-pro
2
+ repo_token: 9tG18WMwC1xpPdDBEGznon01RCp9NusHL
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  .ruby-version
7
7
  Gemfile.lock
8
8
  vendor
9
+ coverage/
data/.travis.yml CHANGED
@@ -4,11 +4,9 @@ rvm:
4
4
  - 2.1
5
5
  - 2.2
6
6
  - ruby-head
7
- - rbx-2
8
7
 
9
8
  os:
10
9
  - linux
11
- - osx
12
10
 
13
11
  gemfile:
14
12
  - Gemfile
@@ -18,4 +16,3 @@ script: bundle exec rake test
18
16
  matrix:
19
17
  allow_failures:
20
18
  - rvm: ruby-head
21
- - rvm: rbx-2
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # fluent-plugin-out-http-ext, a plugin for [Fluentd](http://fluentd.org)
2
2
 
3
+ [![Build Status](https://travis-ci.org/kawasakitoshiya/fluent-plugin-out-http-ext.svg)](https://travis-ci.org/kawasakitoshiya/fluent-plugin-out-http-ext)
4
+ [![Coverage Status](https://coveralls.io/repos/kawasakitoshiya/fluent-plugin-out-http-ext/badge.svg?branch=master&service=github)](https://coveralls.io/github/kawasakitoshiya/fluent-plugin-out-http-ext?branch=master)
5
+
3
6
  **This is a fork of [ento / fluent-plugin-out-http](https://github.com/ento/fluent-plugin-out-http)**
4
7
 
5
8
  A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint
@@ -7,16 +10,17 @@ A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint
7
10
  ## Configuration options
8
11
 
9
12
  <match *>
10
- type http-ext
11
- endpoint_url http://localhost.local/api/<data.id> # <data.id> refres to data.id in the record like {"data"=> {"id"=> 1, "name"=> "foo"}}
12
- http_method put # default: post
13
- serializer json # default: form
14
- rate_limit_msec 100 # default: 0 = no rate limiting
15
- raise_on_error false # default: true
16
- authentication basic # default: none
17
- username alice # default: ''
18
- password bobpop # default: '', secret: true
19
- use_ssl true # default: false
13
+ type http_ext
14
+ endpoint_url http://localhost.local/api/<data.id> # <data.id> refres to data.id in the record like {"data"=> {"id"=> 1, "name"=> "foo"}}
15
+ http_method put # default: post
16
+ serializer json # default: form
17
+ rate_limit_msec 100 # default: 0 = no rate limiting
18
+ raise_on_error false # default: true
19
+ raise_on_http_failure true # default: false
20
+ authentication basic # default: none
21
+ username alice # default: ''
22
+ password bobpop # default: '', secret: true
23
+ use_ssl true # default: false
20
24
  <headers>
21
25
  HeaderExample1 header1
22
26
  HeaderExample2 header2
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-out-http-ext"
5
- gem.version = "0.1.5.4"
5
+ gem.version = "0.1.6"
6
6
  gem.authors = ["Toshiya Kawasaki"]
7
7
  gem.email = ["kawasakitoshiya@gmail.com"]
8
8
  gem.summary = %q{A generic Fluentd output plugin to send logs to an HTTP endpoint with SSL and Header option}
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.add_development_dependency "bundler"
20
20
  gem.add_development_dependency "rake"
21
21
  gem.add_development_dependency "test-unit", ">= 3.1.0"
22
+ gem.add_development_dependency "coveralls"
22
23
  end
@@ -48,9 +48,12 @@ class Fluent::HTTPOutput < Fluent::Output
48
48
  # Raise errors that were rescued during HTTP requests?
49
49
  config_param :raise_on_error, :bool, :default => true
50
50
 
51
+ # Raise errors when HTTP response code was not successful.
52
+ config_param :raise_on_http_failure, :bool, :default => false
53
+
51
54
 
52
55
  # nil | 'none' | 'basic'
53
- config_param :authentication, :string, :default => nil
56
+ config_param :authentication, :string, :default => nil
54
57
  config_param :username, :string, :default => ''
55
58
  config_param :password, :string, :default => '', :secret => true
56
59
 
@@ -167,7 +170,9 @@ class Fluent::HTTPOutput < Fluent::Output
167
170
  else
168
171
  "res=nil"
169
172
  end
170
- $log.warn "failed to #{req.method} #{uri} (#{res_summary})"
173
+ warning = "failed to #{req.method} #{uri} (#{res_summary})"
174
+ $log.warn warning
175
+ raise warning if @raise_on_http_failure
171
176
  end #end unless
172
177
  end # end begin
173
178
  end # end send_request
@@ -0,0 +1,3 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'coveralls'
3
+ Coveralls.wear!
@@ -17,6 +17,7 @@ class HTTPOutputTestBase < Test::Unit::TestCase
17
17
  @prohibited = 0
18
18
  @requests = 0
19
19
  @auth = false
20
+ @status = 200
20
21
  @dummy_server_thread = Thread.new do
21
22
  srv = if ENV['VERBOSE']
22
23
  WEBrick::HTTPServer.new({:BindAddress => '127.0.0.1', :Port => TEST_LISTEN_PORT})
@@ -52,7 +53,7 @@ class HTTPOutputTestBase < Test::Unit::TestCase
52
53
 
53
54
  instance_variable_get("@#{req.request_method.downcase}s").push(record)
54
55
 
55
- res.status = 200
56
+ res.status = @status
56
57
  }
57
58
  srv.mount_proc('/') { |req,res|
58
59
  res.status = 200
@@ -81,11 +82,11 @@ class HTTPOutputTestBase < Test::Unit::TestCase
81
82
  end
82
83
  end
83
84
  cv.signal
84
- }
85
+ }
85
86
  mutex = Mutex.new
86
87
  mutex.synchronize {
87
88
  cv.wait(mutex)
88
- }
89
+ }
89
90
  end
90
91
 
91
92
  def test_dummy_server
@@ -156,6 +157,11 @@ class HTTPOutputTest < HTTPOutputTestBase
156
157
  raise_on_error false
157
158
  ]
158
159
 
160
+ CONFIG_RAISE_ON_HTTP_FAILURE = %[
161
+ endpoint_url http://127.0.0.1:#{TEST_LISTEN_PORT}/api/
162
+ raise_on_http_failure true
163
+ ]
164
+
159
165
  RATE_LIMIT_MSEC = 1200
160
166
 
161
167
  CONFIG_RATE_LIMIT = %[
@@ -189,7 +195,6 @@ class HTTPOutputTest < HTTPOutputTestBase
189
195
  assert_equal '20', record[:form]['field2']
190
196
  assert_equal '10', record[:form]['field3']
191
197
  assert_equal '1', record[:form]['otherfield']
192
- assert_equal URI.encode_www_form_component("あ").upcase, record[:form]['binary'].upcase
193
198
  assert_nil record[:auth]
194
199
 
195
200
  d.emit({ 'field1' => 50, 'field2' => 20, 'field3' => 10, 'otherfield' => 1 })
@@ -251,6 +256,28 @@ class HTTPOutputTest < HTTPOutputTestBase
251
256
  assert_equal 0, @requests
252
257
  end
253
258
 
259
+ def test_http_failure_is_not_raised_on_http_failure_true_and_status_201
260
+ @status = 201
261
+
262
+ d = create_driver CONFIG_RAISE_ON_HTTP_FAILURE
263
+ assert_nothing_raised do
264
+ d.emit({ 'field1' => 50 })
265
+ end
266
+
267
+ @status = 200
268
+ end
269
+
270
+ def test_http_failure_is_raised_on_http_failure_true
271
+ @status = 500
272
+
273
+ d = create_driver CONFIG_RAISE_ON_HTTP_FAILURE
274
+ assert_raise RuntimeError do
275
+ d.emit({ 'field1' => 50 })
276
+ end
277
+
278
+ @status = 200
279
+ end
280
+
254
281
  def test_rate_limiting
255
282
  d = create_driver CONFIG_RATE_LIMIT
256
283
  record = { :k => 1 }
@@ -268,7 +295,7 @@ class HTTPOutputTest < HTTPOutputTestBase
268
295
 
269
296
  wait_msec = 500
270
297
  sleep (last_emit + RATE_LIMIT_MSEC - _current_msec + wait_msec) * 0.001
271
-
298
+
272
299
  assert last_emit + RATE_LIMIT_MSEC < _current_msec, "No longer under rate limiting interval"
273
300
  d.emit(record)
274
301
  d.run
@@ -278,7 +305,7 @@ class HTTPOutputTest < HTTPOutputTestBase
278
305
  def _current_msec
279
306
  Time.now.to_f * 1000
280
307
  end
281
-
308
+
282
309
  def test_auth
283
310
  @auth = true # enable authentication of dummy server
284
311
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-out-http-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiya Kawasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - '>='
87
87
  - !ruby/object:Gem::Version
88
88
  version: 3.1.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: coveralls
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
89
103
  description: A generic Fluentd output plugin to send logs to an HTTP endpoint with
90
104
  SSL and Header option
91
105
  email:
@@ -94,6 +108,7 @@ executables: []
94
108
  extensions: []
95
109
  extra_rdoc_files: []
96
110
  files:
111
+ - .coveralls.yml
97
112
  - .gitignore
98
113
  - .travis.yml
99
114
  - CHANGELOG.md
@@ -104,6 +119,7 @@ files:
104
119
  - fluent-plugin-out-http-ext.gemspec
105
120
  - lib/fluent/plugin/out_http_ext.rb
106
121
  - lib/fluent/test/http_output_test.rb
122
+ - test/plugin/test_helper.rb
107
123
  - test/plugin/test_out_http_ext.rb
108
124
  homepage:
109
125
  licenses:
@@ -131,4 +147,5 @@ specification_version: 4
131
147
  summary: A generic Fluentd output plugin to send logs to an HTTP endpoint with SSL
132
148
  and Header option
133
149
  test_files:
150
+ - test/plugin/test_helper.rb
134
151
  - test/plugin/test_out_http_ext.rb