Sha256: 54bfbc828d1a0e50969ec44298c6e673af371a08e5aef9914df1263a4bcaab36

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

#encoding: utf-8

require 'riemann/babbler'
require 'riemann/babbler/version'
require 'riemann/babbler/start'
require 'configatron'

opts = Hash.new
opts[:config] = File.expand_path('../config.yml', __FILE__)

babbler = Riemann::Babbler::Starter.new(opts, configatron)

describe Riemann::Babbler do

  it 'Merge config' do
    babbler.merge_config
    configatron.riemann.host.should eq 'hostname_does_not_exists'
  end

  it 'Set logger lvl' do
    babbler.set_logger_lvl
    babbler.logger.level.should eq 4
  end

  it 'Load plugins' do
    babbler.load_plugins
    Riemann::Babbler.registered_plugins.should include( Riemann::Babbler::Dummy )
  end

  it 'Started plugins' do
    babbler.started_plugins.should include( Riemann::Babbler::Dummy )
  end

  it 'Parent plugins' do
    babbler.started_plugins.should include( Riemann::Babbler::Dummy2 )
  end

  it 'Custom parent plugin start' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    configatron.plugins.dummy2.to_hash.should include(:run => false)
    dummyplugin.plugin.run.should eq false
    dummyplugin.plugin.interval.should eq 2000 
    dummyplugin.run.should eq 0
  end

  it 'Shell helper' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    dummyplugin.shell("echo 'a' | wc -l").to_i.should eq 1
  end

  it 'RestGet helper' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    dummyplugin.rest_get('http://ya.ru').should include 'yandex.ru'
  end

  it 'TcpPortAviable helper' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    dummyplugin.tcp_port_aviable?('www.ya.ru', 80).should eq true
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
riemann-babbler-1.3.3 spec/default.rb
riemann-babbler-1.3.2 spec/default.rb
riemann-babbler-1.3.1 spec/default.rb
riemann-babbler-1.3.0 spec/default.rb
riemann-babbler-1.2.9 spec/default.rb
riemann-babbler-1.2.8 spec/default.rb
riemann-babbler-1.2.7 spec/default.rb
riemann-babbler-1.2.6 spec/default.rb
riemann-babbler-1.2.5 spec/default.rb
riemann-babbler-1.2.4 spec/default.rb
riemann-babbler-1.2.3 spec/default.rb
riemann-babbler-1.2.2 spec/default.rb
riemann-babbler-1.2.1 spec/default.rb
riemann-babbler-1.2.0 spec/default.rb