Class: Fluent::Test::Driver::Output
Instance Attribute Summary
Attributes inherited from Base
#instance, #logs
Instance Method Summary
collapse
#feed, #feed_to_plugin
Methods inherited from BaseOwner
#configure, #emit_count, #emit_error_event, #emit_event_stream, #error_events, #events, #record_count
Methods inherited from Base
#break_if, #broken?, #configure, #end_if, #instance_shutdown, #instance_start, #stop?
Constructor Details
#initialize(klass, opts: {}, &block) ⇒ Output
Returns a new instance of Output.
29
30
31
32
33
34
35
36
|
# File 'lib/fluent/test/driver/output.rb', line 29
def initialize(klass, opts: {}, &block)
super
raise ArgumentError, "plugin is not an instance of Fluent::Plugin::Output" unless @instance.is_a? Fluent::Plugin::Output
@instance.in_tests = true
@flush_buffer_at_cleanup = nil
@format_hook = nil
@format_results = []
end
|
Instance Method Details
#flush ⇒ Object
55
56
57
58
|
# File 'lib/fluent/test/driver/output.rb', line 55
def flush
@instance.force_flush
Timeout.timeout(10){ sleep 0.1 until !@instance.buffer || @instance.buffer.queue.size == 0 }
end
|
51
52
53
|
# File 'lib/fluent/test/driver/output.rb', line 51
def formatted
@format_results
end
|
#instance_hook_after_started ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/fluent/test/driver/output.rb', line 60
def instance_hook_after_started
super
if @instance.instance_eval{ @custom_format }
@format_hook = format_hook = ->(result){ @format_results << result }
m = Module.new do
define_method(:format) do |tag, time, record|
result = super(tag, time, record)
format_hook.call(result)
result
end
end
@instance.singleton_class.prepend m
end
end
|
#run(flush: true, **kwargs, &block) ⇒ Object
38
39
40
41
|
# File 'lib/fluent/test/driver/output.rb', line 38
def run(flush: true, **kwargs, &block)
@flush_buffer_at_cleanup = flush
super(**kwargs, &block)
end
|
#run_actual(**kwargs, &block) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/fluent/test/driver/output.rb', line 43
def run_actual(**kwargs, &block)
super(**kwargs, &block)
if @flush_buffer_at_cleanup
@instance.force_flush
Timeout.timeout(10){ sleep 0.1 until !@instance.buffer || @instance.buffer.queue.size == 0 }
end
end
|