Sha256: aaae204e3a09f3e7a520fc6172e6da215903903091fa9272df30935a693b17b3

Contents?: true

Size: 1.25 KB

Versions: 78

Compression:

Stored size: 1.25 KB

Contents

require 'helper'
require 'date'
require 'fluent/test/helpers'
require 'json'
require 'fluent/test/driver/filter'
require 'flexmock/test_unit'
require 'fluent/plugin/filter_elasticsearch_genid'

class ElasticsearchGenidFilterTest < Test::Unit::TestCase
  include FlexMock::TestCase
  include Fluent::Test::Helpers

  def setup
    Fluent::Test.setup
  end

  def create_driver(conf='')
    Fluent::Test::Driver::Filter.new(Fluent::Plugin::ElasticsearchGenidFilter).configure(conf)
  end

  def sample_record
    {'age' => 26, 'request_id' => '42', 'parent_id' => 'parent', 'routing_id' => 'routing'}
  end

  def test_configure
    d = create_driver
    assert_equal '_hash', d.instance.hash_id_key
  end

  data("default" => {"hash_id_key" => "_hash"},
       "custom_key" => {"hash_id_key" => "_edited"},
      )
  def test_filter(data)
    d = create_driver("hash_id_key #{data["hash_id_key"]}")
    flexmock(SecureRandom).should_receive(:uuid)
      .and_return("13a0c028-bf7c-4ae2-ad03-ec09a40006df")
    time = event_time("2017-10-15 15:00:23.34567890 UTC")
    d.run(default_tag: 'test') do
      d.feed(time, sample_record)
    end
    assert_equal(Base64.strict_encode64(SecureRandom.uuid),
                 d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
  end
end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
fluent-plugin-elasticsearch-3.4.1 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.4.0 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.3.3 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.3.2 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.3.1 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.3.0 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.2.4 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.2.3 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.2.2 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.2.1 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.2.0 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.1.1 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.1.0 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.0.2 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.0.1 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-3.0.0 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-2.12.5 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-2.12.4 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-2.12.3 test/plugin/test_filter_elasticsearch_genid.rb
fluent-plugin-elasticsearch-2.12.2 test/plugin/test_filter_elasticsearch_genid.rb