Sha256: e1f4e1eda2b111d97f7e21e086ea4f1e8d6ddc60133396bec4b2a58935cd1c7a

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

require 'helper'
require_relative '../plugins'

class ConfigExpanderInputTest < Test::Unit::TestCase
  def setup
    Fluent::Test.setup
  end

  CONFIG = %[
type config_expander
<config>
  type config_expander_test
  tag foobar
  <for x in 1 2 3>
    <node>
      attr1 __x__
    </node>
  </for>
</config>
]

  def create_driver(conf=CONFIG)
    Fluent::Test::Driver::Input.new(Fluent::Plugin::ConfigExpanderInput).configure(conf)
  end

  def test_configure
    d = create_driver
    assert_equal 'foobar', d.instance.tag
    assert_equal 3, d.instance.nodes.size
    assert_equal ['1','2','3'], d.instance.nodes.map{|n| n.attr1 }.sort

    assert_equal false, d.instance.started
    assert_equal false, d.instance.stopped

    d.instance.start()
    assert_equal true, d.instance.started
    assert_equal false, d.instance.stopped

    d.instance.shutdown()
    assert_equal true, d.instance.stopped
  end

  CONFIG2 = %[
type config_expander
hostname testing.node.local
<config>
  type config_expander_test
  tag baz
  <node>
    attr1 ${hostname}
    attr2 ${HOSTNAME}
    attr3 __hostname__
    attr4 __HOSTNAME__
  </node>
</config>
]
  def test_configure_hostname
    d = create_driver CONFIG2
    assert_equal 1, d.instance.nodes.size
    assert_equal 'testing.node.local', d.instance.nodes.first.attr1
    assert_equal 'testing.node.local', d.instance.nodes.first.attr2
    assert_equal 'testing.node.local', d.instance.nodes.first.attr3
    assert_equal 'testing.node.local', d.instance.nodes.first.attr4
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-config-expander-1.0.1 test/plugin/test_in_config_expander.rb
fluent-plugin-config-expander-1.0.0 test/plugin/test_in_config_expander.rb