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