Sha256: e228a2d2cbde1b2eec50aa4621eef9d17a8648e1dd23f3200ff06386db3cd44b

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'helper'

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

  OPTIONS = ["aio", "cpu", "cpu24", "disk", 
             "epoch", "fs", "int", "int24", "io", "ipc", "load", "lock",
             "mem", "net", "page", "page24", "proc", "raw", "socket",
             "swap", "swapold", "sys", "tcp", "udp", "unix", "vm",
             "disk-util", "freespace",
             "top-bio", "top-cpu","top-io",
             "top-mem", "top-oom", "top-io -fc"]

  CONFIG = %[
    tag dstat
    option --aio -cpu
    delay 1
  ]

  def create_driver(conf=CONFIG)
    Fluent::Test::InputTestDriver.new(Fluent::DstatInput).configure(conf)
  end

  def test_configure
    d = create_driver
    assert_equal 1, d.instance.delay
  end

  data do
    hash = {}
    OPTIONS.each do |op|
      hash[op] = op
    end
    hash
  end
  def test_emit(data)
    op = data
    conf = "tag dstat\n option --#{op}\n delay 1"
    emit_with_conf(conf)
  end

  def emit_with_conf(conf)
    d = create_driver(conf)

    d.run do
      sleep 2
    end

    length = `dstat #{d.instance.option} #{d.instance.delay} 1`.split("\n")[0].split("\s").length
    puts `dstat #{d.instance.option} #{d.instance.delay} 3`

    emits = d.emits
    assert_equal true, emits.length > 0
    assert_equal length, emits[0][2]['dstat'].length

    puts "--- #{d.instance.option} ---"
    puts emits[0][2]
    puts "--- end ---"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-dstat-0.3.3 test/plugin/test_in_dstat.rb
fluent-plugin-dstat-0.3.2 test/plugin/test_in_dstat.rb