Sha256: a2b82eee60a81fa0df7c044f977e2dcb061635e0a52e551350f90d03675081a3

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'test_helper'
require 'metriksd/config'
require 'metriksd_reporter'
require 'metriks'

class MetriksdReporterTest < Test::Unit::TestCase
  def test_working_config
    @port = 39283

    @server_config = Metriksd::Config.new

    @server_config.load :registry => {
      :ignore_current_timeslice => false,
      :reporter => {
        :type => 'librato_metrics',
        :email => 'a@b.com',
        :api_key => 'a' * 10
      },
      :server => {
        :type => 'udp',
        :port => @port
      }  
    }

    @server_config.start

    # Wait for eventmachine
    thr = Thread.current; EventMachine.next_tick { thr.wakeup }; Thread.stop

    @server_reporter = @server_config.reporters.first
    @server_reporter.client.persistence = :test
    @server_persister = @server_reporter.queue.persister

    @client_registry = Metriks::Registry.new
    @client_reporter = MetriksdReporter.new(:host => '127.0.0.1', :port => @port,
      :registry => @client_registry, :extras => { :source => Socket.gethostname })

    @client_reporter.start
    @client_registry.timer('client.test.metric').update(5.3)

    @client_reporter.flush
    @client_reporter.stop

    @server_config.stop
    @server_config.join

    assert_not_nil @server_persister.persisted, @server_persister.inspect
    assert @server_persister.persisted.length == 1, @server_persister.persisted.inspect
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metriksd-0.5.0 test/metriksd_reporter_test.rb