Class: Fluent::Test::BufferedOutputTestDriver
- Inherits:
-
InputTestDriver
- Object
- TestDriver
- InputTestDriver
- Fluent::Test::BufferedOutputTestDriver
- Defined in:
- lib/fluent/test/output_test.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
Returns the value of attribute tag.
Attributes inherited from InputTestDriver
#emit_streams, #event_streams, #expected_emits_length, #run_timeout
Attributes inherited from TestDriver
Class Method Summary collapse
Instance Method Summary collapse
- #emit(record, time = EventTime.now) ⇒ Object
- #expect_format(str) ⇒ Object
-
#initialize(klass, tag = 'test', &block) ⇒ BufferedOutputTestDriver
constructor
A new instance of BufferedOutputTestDriver.
- #run(num_waits = 10, &block) ⇒ Object
Methods inherited from InputTestDriver
#emits, #events, #expect_emit, #expected_emits, #records, #register_run_breaking_condition, #register_run_post_condition, #run_should_stop?
Methods inherited from TestDriver
Constructor Details
#initialize(klass, tag = 'test', &block) ⇒ BufferedOutputTestDriver
Returns a new instance of BufferedOutputTestDriver.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fluent/test/output_test.rb', line 52 def initialize(klass, tag='test', &block) super(klass, &block) @entries = [] @expected_buffer = nil @tag = tag def @instance.buffer @buffer end end |
Instance Attribute Details
#tag ⇒ Object
Returns the value of attribute tag.
63 64 65 |
# File 'lib/fluent/test/output_test.rb', line 63 def tag @tag end |
Class Method Details
.buffer ⇒ Object
58 59 60 |
# File 'lib/fluent/test/output_test.rb', line 58 def @instance.buffer @buffer end |
Instance Method Details
#emit(record, time = EventTime.now) ⇒ Object
65 66 67 68 |
# File 'lib/fluent/test/output_test.rb', line 65 def emit(record, time=EventTime.now) @entries << [time, record] self end |
#expect_format(str) ⇒ Object
70 71 72 |
# File 'lib/fluent/test/output_test.rb', line 70 def expect_format(str) (@expected_buffer ||= '') << str end |
#run(num_waits = 10, &block) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/fluent/test/output_test.rb', line 74 def run(num_waits = 10, &block) result = nil super(num_waits) { block.call if block es = ArrayEventStream.new(@entries) buffer = @instance.format_stream(@tag, es) if @expected_buffer assert_equal(@expected_buffer, buffer) end chunk = if @instance.instance_eval{ @chunk_key_tag } @instance.buffer.generate_chunk(@instance.(@tag, nil, nil)).staged! else @instance.buffer.generate_chunk(@instance.(nil, nil, nil)).staged! end chunk.concat(buffer, es.size) begin result = @instance.write(chunk) ensure chunk.purge end } result end |