Sha256: 6642764e15b541f26c940f8721488df169fdd24b838f555053d0b8ef3bb51178

Contents?: true

Size: 963 Bytes

Versions: 21

Compression:

Stored size: 963 Bytes

Contents

require 'socket'
require 'timeout'
require 'kurchatov/riemann/client'
require 'yaml'

PORT = 5555
HOST = '127.0.0.1'
RECEIVE_INTERVAL = 60

server = TCPServer.new(HOST, PORT)
events = []
puts "Run riemann server at #{HOST}:#{PORT}"

Timeout::timeout(RECEIVE_INTERVAL) {
  client = server.accept
  loop do
    line = client.read(4)
    break if line.nil? || line.size != 4
    length = line.unpack('N').first
    str = client.read(length)
    message = Kurchatov::Riemann::Message.decode(str)
    message.events.each do |event|
      events << event
    end
  end
}

data = YAML.load_file('./tests/data/event.yml')
events.each do |e|
  data["events"].each do |d|
    next unless d[:service] == e[:service]
    next if d[:result] == e[:state]
    raise "Recieved state: #{e[:state]}, data state: #{d[:result]}. \n Data: #{d.inspect} \n Event: #{e.inspect}"
  end
end

raise "Not all events recieved" unless 3 * data["events"].count == events.count
puts "All done!"

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
kurchatov-0.2.1 tests/server.rb
kurchatov-0.2.0 tests/server.rb
kurchatov-0.1.8 tests/server.rb
kurchatov-0.1.7 tests/server.rb
kurchatov-0.1.6 tests/server.rb
kurchatov-0.1.5 tests/server.rb
kurchatov-0.1.4 tests/server.rb
kurchatov-0.1.3 tests/server.rb
kurchatov-0.1.2 tests/server.rb
kurchatov-0.1.1 tests/server.rb
kurchatov-0.1.0 tests/server.rb
kurchatov-0.0.9 tests/server.rb
kurchatov-0.0.8.pre.3 tests/server.rb
kurchatov-0.0.7.pre.4 tests/server.rb
kurchatov-0.0.8.pre.2 tests/server.rb
kurchatov-0.0.8.pre.1 tests/server.rb
kurchatov-0.0.7 tests/server.rb
kurchatov-0.0.7.pre.3 tests/server.rb
kurchatov-0.0.7.pre.2 tests/server.rb
kurchatov-0.0.7.pre.1 tests/server.rb