Sha256: ad2baa3ebd170c857ec138ed7ff164cc9fafecfee38c25f398c1254bb9eea064

Contents?: true

Size: 1.89 KB

Versions: 18

Compression:

Stored size: 1.89 KB

Contents

# Copyright 2018 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'fluent/engine'
require 'fluent/event'
require 'fluent/test/input_test'

module Fluent
  module Test
    # rubocop:disable Style/ClassVars
    class BufferedOutputTestDriver < InputTestDriver
      @@run_method = BufferedOutputTestDriver.instance_method(:run)
      def run(num_waits = 0)
        @@run_method.bind(self).call(num_waits)
      end
    end
    # rubocop:enable Style/ClassVars
  end
end

module Fluent
  module Test
    # Similar to the standard BufferedOutputTestDriver, but allows multiple tags
    # to exist in one chunk.
    class MultiTagBufferedOutputTestDriver < InputTestDriver
      def initialize(klass, &block)
        super(klass, &block)
        @entries = []
      end

      def emit(tag, record, time = Engine.now)
        es = ArrayEventStream.new([[time, record]])
        data = @instance.format_stream(tag, es)
        @entries << data
        self
      end

      def run(num_waits = 0)
        result = nil
        super(num_waits) do
          chunk = @instance.buffer.generate_chunk(
            @instance.metadata(nil, nil, nil)).staged!
          @entries.each do |entry|
            chunk.concat(entry, 1)
          end

          begin
            result = @instance.write(chunk)
          ensure
            chunk.purge
          end
        end
        result
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fluent-plugin-google-cloud-0.8.7 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.8.6 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.8.5 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.8.4 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.8.3 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.8.2 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.8.1 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.8.0 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.30 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.29 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.28 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.27 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.26 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.25 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.24 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.23 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.22 test/plugin/test_driver.rb
fluent-plugin-google-cloud-0.7.21 test/plugin/test_driver.rb