fluentd 0.12.0.pre.3 → 0.12.0

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.

@@ -1,13 +1,38 @@
1
1
  require_relative 'helper'
2
2
 
3
3
  module FluentTest
4
+ class FluentTestInput < ::Fluent::Input
5
+ ::Fluent::Plugin.register_input('test_in', self)
6
+
7
+ attr_reader :started
8
+
9
+ def start
10
+ @started = true
11
+ end
12
+
13
+ def shutdown
14
+ @started = false
15
+ end
16
+ end
17
+
4
18
  class FluentTestOutput < ::Fluent::Output
19
+ ::Fluent::Plugin.register_output('test_out', self)
20
+
5
21
  def initialize
6
22
  super
7
23
  @events = Hash.new { |h, k| h[k] = [] }
8
24
  end
9
25
 
10
26
  attr_reader :events
27
+ attr_reader :started
28
+
29
+ def start
30
+ @started = true
31
+ end
32
+
33
+ def shutdown
34
+ @started = false
35
+ end
11
36
 
12
37
  def emit(tag, es, chain)
13
38
  es.each { |time, record|
@@ -17,6 +42,8 @@ module FluentTest
17
42
  end
18
43
 
19
44
  class FluentTestErrorOutput < ::Fluent::BufferedOutput
45
+ ::Fluent::Plugin.register_output('test_out_error', self)
46
+
20
47
  def format(tag, time, record)
21
48
  raise "emit error!"
22
49
  end
@@ -27,6 +54,8 @@ module FluentTest
27
54
  end
28
55
 
29
56
  class FluentTestFilter < ::Fluent::Filter
57
+ ::Fluent::Plugin.register_filter('test_filter', self)
58
+
30
59
  def initialize(field = '__test__')
31
60
  super()
32
61
  @num = 0
@@ -34,6 +63,15 @@ module FluentTest
34
63
  end
35
64
 
36
65
  attr_reader :num
66
+ attr_reader :started
67
+
68
+ def start
69
+ @started = true
70
+ end
71
+
72
+ def shutdown
73
+ @started = false
74
+ end
37
75
 
38
76
  def filter(tag, time, record)
39
77
  record[@field] = @num
@@ -0,0 +1,135 @@
1
+ require 'fluent/event_router'
2
+ require_relative 'test_plugin_classes'
3
+
4
+ class RootAgentTest < ::Test::Unit::TestCase
5
+ include Fluent
6
+ include FluentTest
7
+
8
+ def test_initialize
9
+ ra = RootAgent.new
10
+ assert_equal 0, ra.instance_variable_get(:@suppress_emit_error_log_interval)
11
+ assert_nil ra.instance_variable_get(:@next_emit_error_log_time)
12
+ end
13
+
14
+ data(
15
+ 'suppress interval' => [{:suppress_interval => 30}, {:@suppress_emit_error_log_interval => 30}],
16
+ 'without source' => [{:without_source => true}, {:@without_source => true}]
17
+ )
18
+ def test_initialize_with_opt(data)
19
+ opt, expected = data
20
+ ra = RootAgent.new(opt)
21
+ expected.each { |k, v|
22
+ assert_equal v, ra.instance_variable_get(k)
23
+ }
24
+ end
25
+
26
+ sub_test_case 'configure' do
27
+ setup do
28
+ @ra = RootAgent.new
29
+ stub(Engine).root_agent { @ra }
30
+ end
31
+
32
+ def configure_ra(conf_str)
33
+ conf = Config.parse(conf_str, "(test)", "(test_dir)", true)
34
+ @ra.configure(conf)
35
+ @ra
36
+ end
37
+
38
+ test 'empty' do
39
+ ra = configure_ra('')
40
+ assert_empty ra.inputs
41
+ assert_empty ra.labels
42
+ assert_empty ra.outputs
43
+ assert_empty ra.filters
44
+ [:@started_inputs, :@started_outputs, :@started_filters].each { |k|
45
+ assert_empty ra.instance_variable_get(k)
46
+ }
47
+ assert_nil ra.context
48
+ assert_nil ra.error_collector
49
+ end
50
+
51
+ test 'with plugins' do
52
+ # check @type and type in one configuration
53
+ conf = <<-EOC
54
+ <source>
55
+ @type test_in
56
+ @id test_in
57
+ </source>
58
+ <filter>
59
+ type test_filter
60
+ id test_filter
61
+ </filter>
62
+ <match **>
63
+ @type relabel
64
+ @id test_relabel
65
+ @label @test
66
+ </match>
67
+ <label @test>
68
+ <match **>
69
+ type test_out
70
+ id test_out
71
+ </match>
72
+ </label>
73
+ <label @ERROR>
74
+ <match>
75
+ @type null
76
+ </match>
77
+ </label>
78
+ EOC
79
+ ra = configure_ra(conf)
80
+ assert_kind_of FluentTestInput, ra.inputs.first
81
+ assert_kind_of RelabelOutput, ra.outputs.first
82
+ assert_kind_of FluentTestFilter, ra.filters.first
83
+ [:@started_inputs, :@started_outputs, :@started_filters].each { |k|
84
+ assert_empty ra.instance_variable_get(k)
85
+ }
86
+ assert ra.error_collector
87
+
88
+ %W(@test @ERROR).each { |label_symbol|
89
+ assert_include ra.labels, label_symbol
90
+ assert_kind_of Label, ra.labels[label_symbol]
91
+ }
92
+
93
+ test_label = ra.labels['@test']
94
+ assert_kind_of FluentTestOutput, test_label.outputs.first
95
+ assert_equal ra, test_label.root_agent
96
+
97
+ error_label = ra.labels['@ERROR']
98
+ assert_kind_of NullOutput, error_label.outputs.first
99
+ assert_kind_of RootAgent::RootAgentProxyWithoutErrorCollector, error_label.root_agent
100
+ end
101
+ end
102
+
103
+ sub_test_case 'start/shutdown' do
104
+ setup do
105
+ @ra = RootAgent.new
106
+ @ra.configure(Config.parse(<<-EOC, "(test)", "(test_dir)", true))
107
+ <source>
108
+ @type test_in
109
+ @id test_in
110
+ </source>
111
+ <filter>
112
+ type test_filter
113
+ id test_filter
114
+ </filter>
115
+ <match **>
116
+ @type test_out
117
+ @id test_out
118
+ </match>
119
+ EOC
120
+ @ra
121
+ end
122
+
123
+ test 'plugin status' do
124
+ @ra.start
125
+ assert_true @ra.inputs.first.started
126
+ assert_true @ra.filters.first.started
127
+ assert_true @ra.outputs.first.started
128
+
129
+ @ra.shutdown
130
+ assert_false @ra.inputs.first.started
131
+ assert_false @ra.filters.first.started
132
+ assert_false @ra.outputs.first.started
133
+ end
134
+ end
135
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0.pre.3
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -285,7 +285,6 @@ files:
285
285
  - COPYING
286
286
  - ChangeLog
287
287
  - Gemfile
288
- - Gemfile.cool.io.1.1.1
289
288
  - README.md
290
289
  - Rakefile
291
290
  - bin/fluent-cat
@@ -434,6 +433,7 @@ files:
434
433
  - test/test_output.rb
435
434
  - test/test_parser.rb
436
435
  - test/test_plugin_classes.rb
436
+ - test/test_root_agent.rb
437
437
  homepage: http://fluentd.org/
438
438
  licenses: []
439
439
  metadata: {}
@@ -448,9 +448,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
448
448
  version: 1.9.3
449
449
  required_rubygems_version: !ruby/object:Gem::Requirement
450
450
  requirements:
451
- - - ">"
451
+ - - ">="
452
452
  - !ruby/object:Gem::Version
453
- version: 1.3.1
453
+ version: '0'
454
454
  requirements: []
455
455
  rubyforge_project:
456
456
  rubygems_version: 2.2.2
@@ -513,3 +513,4 @@ test_files:
513
513
  - test/test_output.rb
514
514
  - test/test_parser.rb
515
515
  - test/test_plugin_classes.rb
516
+ - test/test_root_agent.rb
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org/'
2
-
3
- gem 'cool.io', '= 1.1.1'
4
- gemspec