Sha256: 01b866c758230f45cbc03bb2b4d92ea54b2adacb0ce0eb087698227bfc6ebaae

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'helper'

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

  CONFIG = %[
    unit minute
    tag monitor.test
    input_tag_remove_prefix test
    monitor_key field1
    percentiles 80,90
  ]

  def create_driver(conf = CONFIG, tag='test.input')
    Fluent::Test::OutputTestDriver.new(Fluent::NumericMonitorOutput, tag).configure(conf)
  end

  def test_configure
    #TODO
  end

  def test_count_initialized
    #TODO
  end

  def test_countups
    #TODO
  end

  def test_stripped_tag
    d = create_driver
    assert_equal 'input', d.instance.stripped_tag('test.input')
    assert_equal 'test.input', d.instance.stripped_tag('test.test.input')
    assert_equal 'input', d.instance.stripped_tag('input')
  end

  def test_generate_output
    #TODO
  end

  def test_emit
    d1 = create_driver(CONFIG, 'test.tag1')
    d1.run do
      10.times do
        d1.emit({'field1' => 0})
        d1.emit({'field1' => '1'})
        d1.emit({'field1' => 2})
        d1.emit({'field1' => '3'})
        d1.emit({'field1' => 4})
        d1.emit({'field1' => 5})
        d1.emit({'field1' => 6})
        d1.emit({'field1' => 7})
        d1.emit({'field1' => 8})
        d1.emit({'field1' => 9})
      end
    end
    r1 = d1.instance.flush
    assert_equal 0, r1['tag1_min']
    assert_equal 9, r1['tag1_max']
    assert_equal 4.5, r1['tag1_avg']
    assert_equal 7, r1['tag1_percentile_80']
    assert_equal 8, r1['tag1_percentile_90']
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-numeric-monitor-0.0.2 test/plugin/test_out_numeric_monitor.rb
fluent-plugin-numeric-monitor-0.0.1 test/plugin/test_out_numeric_monitor.rb