fluent-plugin-http_shadow 0.0.4 → 0.0.5

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: c19b229a7b1bd67fea1c6279fa209c8434be9acc
4
- data.tar.gz: 8b4793f5a1749fa6847b1d6a4b2cb01f1c32ead2
3
+ metadata.gz: 432423d0f4953a8ae5c7efb44e4ad5340ef32cf2
4
+ data.tar.gz: ab0ba60220b359a4208319d35d36459b09bc2f59
5
5
  SHA512:
6
- metadata.gz: 2a24e4dbcad9d413b20b9f7e5fa0d6acd0bf36f2020e448a48a3e7201b6886b9cbd525958fbfb6ea789dcba315032c3d3784abd1b038fa28e9d81f195930b650
7
- data.tar.gz: f601a9bcb878b7831140bae2755d183a29665f9d6f22e569972b3136a36df3f9aecda4a6951348aac695e81890f909688f3404886efcd14f79cd57b0395a0b10
6
+ metadata.gz: 6eab790e3e9203f1af7c5c0cc7200324a7a8955cea70396804f8f7db7074cc7900e0b69a9e790efcf17895d998e93c0344be5f7caf6e7236d9c84da17189205d
7
+ data.tar.gz: ea99cb8163843fcab9f72258764c522e607227a63a0bf44690c56af70e977b038d00c7007287a44f164c7f3966bbaf73ed42415f929b968810936961e4e757ca
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-http_shadow"
5
- gem.version = "0.0.4"
5
+ gem.version = "0.0.5"
6
6
  gem.summary = %q{copy http request. use shadow proxy server.}
7
7
  gem.description = %q{copy http request. use shadow proxy server.}
8
8
  gem.license = "MIT"
@@ -28,7 +28,10 @@ module Fluent
28
28
  if @host.nil? && @host_hash.nil?
29
29
  raise ConfigError, "out_http_shadow: required to @host or @host_hash."
30
30
  end
31
+ end
31
32
 
33
+ def start
34
+ super
32
35
  @regexp = /\$\{([^}]+)\}/
33
36
  @path_format = ERB.new(@path_format.gsub(@regexp, "<%=record['" + '\1' + "'] %>"))
34
37
 
@@ -36,10 +39,6 @@ module Fluent
36
39
  @cookies = get_formatter(@cookie_hash)
37
40
  end
38
41
 
39
- def start
40
- super
41
- end
42
-
43
42
  def shutdown
44
43
  super
45
44
  end
@@ -54,7 +53,14 @@ module Fluent
54
53
  records << record
55
54
  end
56
55
  sampling_size = (records.size * (@rate * 0.01)).to_i
57
- send_request_parallel(records.sample(sampling_size))
56
+ if @rate > 100
57
+ orig_records = records.dup
58
+ loop do
59
+ records.concat(orig_records)
60
+ break if sampling_size < records.size
61
+ end
62
+ end
63
+ send_request_parallel(records.first(sampling_size))
58
64
  end
59
65
 
60
66
  private
@@ -4,12 +4,39 @@ class HttpShadowOutputTest < Test::Unit::TestCase
4
4
  Fluent::Test.setup
5
5
  end
6
6
 
7
- def create_driver(conf)
7
+ def create_driver(conf = CONFIG, tag = 'test')
8
+ Fluent::Test::BufferedOutputTestDriver.new(Fluent::HttpShadowOutput, tag).configure(conf)
8
9
  end
9
10
 
10
11
  def test_configure
12
+ d = create_driver %[
13
+ host google.com
14
+ path_format ${path}
15
+ method_key method
16
+ path_format ${url}
17
+ method_key method
18
+ header_hash { "Referer": "${referer}", "X-Forwarded-For": "${ip_address}" }
19
+ cookie_hash { "iij-stg1_session": "${session_id}", "___IPROS_UUID_": "${uuid}"}
20
+ flush_interval 10
21
+ ]
22
+ assert_equal 'google.com', d.instance.host
23
+ assert_equal 'method', d.instance.method_key
24
+ assert_equal '${url}', d.instance.path_format
11
25
  end
12
26
 
27
+ def test_configure_error
28
+ assert_raise(Fluent::ConfigError) do
29
+ d = create_driver %[
30
+ path_format ${path}
31
+ method_key method
32
+ path_format ${url}
33
+ method_key method
34
+ header_hash { "Referer": "${referer}", "X-Forwarded-For": "${ip_address}" }
35
+ cookie_hash { "iij-stg1_session": "${session_id}", "___IPROS_UUID_": "${uuid}"}
36
+ flush_interval 10
37
+ ]
38
+ end
39
+ end
13
40
  end
14
41
 
15
42
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-http_shadow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Toyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus